#include <bits/stdc++.h>
using namespace std;
int f(long long x) {
  if (x == 0) return 0;
  int cnt = 0;
  while (x) {
    cnt += x % 10;
    x /= 10;
  }
  return cnt;
}
int main() {
  long long n;
  scanf("%I64d", &n);
  long long c = 0;
  while (c <= n) {
    c = c * 10 + 9;
  }
  c = c / 10;
  printf("%d\n", f(c) + f(n - c));
  return 0;
}
