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