n = int(input()) t = 1 ans = -1 for i in range(1, 100000): p = t * 9 if(p * p >= n): ans = i break; t = t * 10 + 1 print(ans)