#include using namespace std; int main(int argc, const char* argv[]) { uint64_t N; cin >> N; uint64_t b = (uint64_t)1e9 + 1; // 1~9 // 11~99 // 111~999 // ... // 11111111~99999999 int cnt = 0; N /= b; while (N > 0) { cnt += N >= 10 ? 9 : N % 10; N /= 10; } cout << cnt << endl; return 0; }