#include <bits/stdc++.h>   #pragma warning(disable : 4996)   #pragma comment(linker,  /STACK:666000000 )   using namespace std;   const int INF = (1 << 30) - 1;   const long double EPS = 1e-9;   const long double PI = fabs(atan2(0.0, -1.0));   int n;   void load() { cin >> n; }   const int SZ = 1010;   int sv[SZ];   int rec(const int v) {     if (v < SZ && -1 != sv[v]) return sv[v];     bool can[10];     int p9;     memset(can, false, sizeof(can));     {       int p = 0;       int tmp = v;       while (tmp != 0) {         can[tmp % 10] = true;         if (9 == tmp % 10) p9 = p;         tmp /= 10;         p *= 10;       }     }     if (v >= SZ) {       if (can[9] && p9 > 10) {         int cnt = 9 * (p9 / 10) - 8;         return cnt + rec(v - cnt * 9);       }       for (int i = 9; i >= 1; i--)         if (can[i]) return 1 + rec(v - i);     }     int res = INT_MAX;     for (int i = 1; i <= 9; i++)       if (can[i]) res = min(res, 1 + rec(v - i));     if (v < SZ) sv[v] = res;     return res;   }   void solve() {     memset(sv, -1, sizeof(sv));     sv[0] = 0;     int res = rec(n);     cout << res;   }   int main() {     load();     solve();     return 0;   }   