n = input() l = str(n) if len(l) == 1: a = 9 b = 10 - 1 print(a + b) else: a = 9 b = 10 * len(l) // 2 print(a + b)