while True:
    try:
        n = int(input())
        res = []
        for i in range(0,n + 1):
            if str(i**2)[-len(str(i)):] == str(i):#或者用endswith方法,if str(i**2).endswith(str(i)):
                res.append(i)
        print(len(res))
    except:
        break