import itertools def is_kaibun(s): n = len(s) for i in xrange(n/2): if s[i] != s[n-i-1]: return False return True N = input() M = 10**9 a = N / M if (a == 0): print 0 exit() s = str(a) b = len(s) ans = 0 for i in xrange(1, b+1): if (i == b): ans += 10**(i/2+i%2-1) * (int(s[0])-1) elif i == 1: ans += 9 else: ans += 10**(i/2+i%2) keta = max(b-2, 0) keta = keta/2 + keta%2 if keta == 0: nnn = a*10**9 + a if nnn <= N: ans += 1 print ans exit() for p in itertools.product('0123456789', repeat=keta): orikaeshi = p[::-1] if len(p) % 2 == 1: orikaeshi = orikaeshi[1:] nnn = int(s[0] + ''.join(p) + ''.join(orikaeshi) + s[0]) nnn = nnn*10**9 + nnn if int(nnn) <= N: ans += 1 print ans