def f(s, flag): if s == "": return 0 if len(s) == 1: return int(s) a, b = int(s[0]), int(s[-1]) v = a * (pow(10, (len(s) - 1)//2)) if a <= b: v += f(s[1:-1], 0) if flag: v += f(str(10**(len(s) - 1) - 1), 0) return v N = int(input()) ten = 10 ** 9 if N < ten + 1: print(0) exit() a, b = N // ten, N % ten if a > b: a -= 1 print(f(str(a), 1))