x = int(input()) def hansu(x: int): count = 0 for i in range(1, x+1): n = list(map(int, str(i))) # 110 -> [1, 1, 0] if i < 100: # 1~99는 모두 한수이다. count += 1 elif n[0] - n[1] == n[1] - n[2]: count += 1 return count print(hansu(x))