1 of 4

GNU sed, 16 + 1(r flag) = 17 bytes

s:.*([^0]0*):\1:

It works by deleting everyhting until the right-most nonzero digit that is followed by trailing zeros or nothing at all.

Test examples: the script can handle multiple inputs, one per line

sed -rf efficient_count.sed << EOF
> 2
> 10
> 11
> 30
> 99
> 100
> 120
> 200
> EOF
2
10
1
30
9
100
20
200