#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  while (n >= 10)
    if (n % 10 == 9) {
      ans += n % 10;
      n /= 10;
    } else {
      ans += 10 + n % 10;
      n = n / 10 - 1;
    }
  cout << ans + n;
  return 0;
}
