#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<bitset> usingnamespace std; #define int long long typedeflonglong ll; #define MAXN 1006 #define pb push_back #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define inf 0x3f3f3f3f #define cmx( a , b ) a = max( a , b ) #define cmn( a , b ) a = min( a , b ) #define upd( a , b ) ( a = ( a + b ) % P ) //#define P 1000000007 int n; int f[19][10][10] , re[19][10][10]; voidinit(){ for( int i = 0 ; i <= 9 ; ++ i ) for( int j = 0 ; j <= 9 ; ++ j ) if( i < j ) f[1][i][j] = 1 , re[1][i][j] = 10 + i - j; else f[1][i][j] = 2 , re[1][i][j] = 10 - j; for( int i = 2 ; i <= 18 ; ++ i ) for( int j = 0 ; j <= 9 ; ++ j ) for( int k = 0 ; k <= 9 ; ++ k ) { re[i][j][k] = j; for( int s = 9 ; s >= 0 ; -- s ) f[i][j][k] += f[i-1][re[i][j][k]][max( s , k )], re[i][j][k] = re[i-1][re[i][j][k]][max( s , k )]; } } int num[19]; intmake_your_dream_come_true( int x ){ int fk = 0; while( x ) num[++ fk] = x % 10 , x /= 10; int cur = num[1] , ans = 0; for( int i = 2 ; i <= fk ; ++ i ) { while( num[i] != 9 ) { int mx = 0; for( int j = i ; j <= fk ; ++ j ) cmx( mx , num[j] ); if( !mx ) break; ans += f[i - 1][cur][mx]; cur = re[i - 1][cur][mx]; -- num[i]; for( int j = i ; num[j] < 0 ; ++ j ) num[j] = 9 , -- num[j + 1]; } } for( int i = fk ; i >= 2 ; -- i ) while( num[i] ) ans += f[i-1][cur][num[i]] , cur = re[i-1][cur][num[i]] , -- num[i]; if( cur ) ++ ans; return ans; } signedmain(){ cin >> n; init(); cout << make_your_dream_come_true( n ) << endl; } /* * Things you should pay attention to * inf is big enough? * out of bounds? * long long ? */