#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, s = 0;
  cin >> n;
  while (n % 10 == 9) {
    s += 9, n /= 10;
  }
  while (n >= 10) {
    s += n % 10 + 9, n /= 10;
  }
  cout << n + s << endl;
  return 0;
}
