#include <bits/stdc++.h>
using namespace std;
inline void read(long long &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
long long n, res;
int main() {
  read(n);
  while (n) {
    if (n >= 10 && n % 10 < 9) res += 10, n -= 10;
    res += n % 10;
    n /= 10;
  }
  cout << res;
  return 0;
}
