n = input() print(len(n) * 9 + 9)