#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
using namespace std;
mt19937 rnd(time(0));
const long long maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18;
const double eps = 1e-9, pi = acos(-1);
string s;
long long get(long long x) {
  long long ans = 0;
  while (x) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
void solve() {
  cin >> s;
  long long d1 = 0, d2 = 0;
  for (long long i = 0; i < (long long)s.size(); ++i) {
    d1 *= 10;
    d1 += s[i] - '0';
  }
  for (long long i = 0; i < (long long)s.size() - 1; ++i) {
    d2 *= 10;
    d2 += 9;
  }
  cout << get(d1 - d2) + get(d2);
}
signed main() {
  srand(time(0));
  cout.precision(10);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
