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