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