N = int(input()) def check(target): buf = str(target) mid = len(buf)//2 head = buf[:mid] tail = reversed(buf[mid:]) zipped = all(list(map(lambda x:x[0]==x[1], zip(head, tail)))) return zipped base = 1000000001 mag = 1 checked = 0 while True: target = mag*base if N < target: break if check(target) == True: checked += 1 mag+=1 print(checked)