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