#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   long long a[20][10][10], b[20][10][10], c[20];   int read_int() {     int a = 0;     int b = 1, c = getchar();     if (c ==  - )       b = -1;     else       a = c - 48;     while ((c = getchar()) !=     && c !=   n ) a = a * 10 + c - 48;     a *= b;     return a;   }   int findmax(long long n) {     long long temp = n;     int m = 0;     while (temp > 0) {       if (temp % 10 > m) m = temp % 10;       temp = temp / 10;     }     return m;   }   int main() {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     long long n;     cin >> n;     long long m, total;     for (int l = 0; l < 19; l++)       for (int x = 9; x >= 0; x--)         for (int y = 0; y <= 9; y++) {           total = 0;           if (!l)             if (!x)               if (y) {                 b[l][x][y] = 1;                 a[l][x][y] = 0;               } else {                 b[l][x][y] = 0;                 a[l][x][y] = 0;               }             else if (x > y) {               a[l][x][y] = y + 10 - x;               b[l][x][y] = 1;             } else {               a[l][x][y] = 10 - x;               b[l][x][y] = 2;             }           else {             total = 0;             m = y;             for (int j = 9; j >= 0; j--) {               total += b[l - 1][x > j ? x : j][m];               m = a[l - 1][x > j ? x : j][m];             }             a[l][x][y] = m;             b[l][x][y] = total;           }         }     m = n % 10;     long long K = n / 10, res = 0;     int len = 0;     while (1) {       while (K % 10 != 9 && K) {         res += b[len][findmax(K)][m];         m = a[len][findmax(K)][m];         K--;       }       if (!K) {         res += b[len][0][m];         break;       }       K /= 10;       len++;     }     cout << res << endl;     return 0;   }   