import math
a = 2
n = 123456
L = math.log(a, 10)
lower = n
while lower >= 10: lower /= 10
lower = math.log(lower, 10)
upper = n+1
while upper >= 10: upper /= 10
upper = math.log(upper, 10)
b = 0
x = 0
while not (lower <= x%1 < upper):
b += 1
x += L
print(b)