Hello Miloud,
You can you following formula for the same.

=IF(A1<=9,1,IF(A1<=999,2,IF(A1<=1000,3,0)))

regards