///0-0 : what is your motivation, quan606303?
///quan606303 : Hutao
/*idea :
*/
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define file(a) freopen(a".inp","r",stdin); freopen(a".out","w",stdout);
using namespace std;
const int MOD=1e9+7;
const int maxn=1e6+7;
int n;
int max_num(int x)
{
int maxx=0;
while (x!=0)
{
maxx=max(maxx,x%10);
x/=10;
}
return maxx;
}
int len(int x)
{
int cnt=0;
while (x!=0)
{
x/=10;
cnt++;
}
return cnt;
}
void sub1()
{
int ans=0;
while (n!=0)
{
ans++;
n-=max_num(n);
}
cout<<ans;
}
pair<int,int> dp[10][maxn];
int p[15];
void sub2()
{
for (int digit=0;digit<=9;digit++)
{
for (int i=0;i<maxn;i++)
{
int cnt=max(digit,max_num(i));
if (i-cnt<=0)dp[digit][i]={1,i-cnt};
else dp[digit][i]={dp[digit][i-cnt].fi+1,dp[digit][i-cnt].se};
}
}
int ans=0;
while (n!=0)
{
//cout<<n<<endl;
int cnt=n;
int left=cnt%1000000;
int right=cnt/1000000;
int tam=max_num(right);
pair<int,int> cnt2=dp[tam][left];
//cout<<cnt2.fi<<" "<<cnt2.se<<" "<<tam<<" "<<left<<endl;
ans+=cnt2.fi;
cnt=right*1000000+cnt2.se;
n=cnt;
}
cout<<ans;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
file("DIGIT");
cin>>n;
sub2();
return 0;
}
Ly8vMC0wIDogd2hhdCBpcyB5b3VyIG1vdGl2YXRpb24sIHF1YW42MDYzMDM/Ci8vL3F1YW42MDYzMDMgOiBIdXRhbwovKmlkZWEgOiAKCgoKKi8KI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIElOVE1BWCBJTlRfTUFYCiNkZWZpbmUgSU5UTUlOIElOVF9NSU4KI2RlZmluZSBMT05HTUFYIExMT05HX01BWAojZGVmaW5lIExPTkdNSU4gTExPTkdfTUlOCiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBtZW1mdWxsKGEsYikgbWVtc2V0KGEsYixzaXplb2YoYSkpOwojZGVmaW5lIGVuZGwgJ1xuJwojZGVmaW5lIGZpbGUoYSkgZnJlb3BlbihhIi5pbnAiLCJyIixzdGRpbik7IGZyZW9wZW4oYSIub3V0IiwidyIsc3Rkb3V0KTsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE1PRD0xZTkrNzsKY29uc3QgaW50IG1heG49MWU2Kzc7CmludCBuOwppbnQgbWF4X251bShpbnQgeCkKewogICAgaW50IG1heHg9MDsKICAgIHdoaWxlICh4IT0wKQogICAgewogICAgICAgIG1heHg9bWF4KG1heHgseCUxMCk7CiAgICAgICAgeC89MTA7CiAgICB9CiAgICByZXR1cm4gbWF4eDsKfQppbnQgbGVuKGludCB4KQp7CiAgICBpbnQgY250PTA7CiAgICB3aGlsZSAoeCE9MCkKICAgIHsKICAgICAgICB4Lz0xMDsKICAgICAgICBjbnQrKzsKICAgIH0KICAgIHJldHVybiBjbnQ7Cn0Kdm9pZCBzdWIxKCkKewogICAgaW50IGFucz0wOwogICAgd2hpbGUgKG4hPTApCiAgICB7CiAgICAgICAgYW5zKys7CiAgICAgICAgbi09bWF4X251bShuKTsKICAgIH0KICAgIGNvdXQ8PGFuczsKfQpwYWlyPGludCxpbnQ+IGRwWzEwXVttYXhuXTsKaW50IHBbMTVdOwp2b2lkIHN1YjIoKQp7CiAgICBmb3IgKGludCBkaWdpdD0wO2RpZ2l0PD05O2RpZ2l0KyspCiAgICB7CiAgICAgICAgZm9yIChpbnQgaT0wO2k8bWF4bjtpKyspCiAgICAgICAgewogICAgICAgICAgICBpb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