n=int(input())//-~10**9;c=0
for x in range(1,10**5):
    b=d=e=str(x);b=b[::-1];d+=b;e+=b[1:]
    if int(d)<=n:c+=1
    if int(e)<=n:c+=1
print(c)