n = input().strip() k = len(n) ans = 0 # Count palindromes for all lengths shorter than k for i in range(1, k): ans += 9 * (10 ** ((i - 1) // 2)) m = (k + 1) // 2 # ceil(k/2) prefix = n[:m] # Construct the palindrome from the prefix if k % 2 == 0: constructed = prefix + prefix[::-1] else: constructed = prefix + prefix[:-1][::-1] # Determine the maximum valid prefix if int(constructed) > int(n): max_p = int(prefix) - 1 else: max_p = int(prefix) min_p = 10 ** (m - 1) # Calculate the count of valid prefixes and add to the answer count = max(0, max_p - min_p + 1) if max_p >= min_p else 0 ans += count print(ans)