/*
TASK:sub
LANG:C++
*/
#include<iostream>
using namespace std;
int main()
{
    unsigned n,z,br=0;
    cin>>n;
    do
    {
        z=n;
        int b[7],q,m=0;
        while(z!=0)
        {
            b[m++]=z%10;
            z/=10;
            q=m-1;
        }
        int max=0;
        for(int i=0; i<=q; i++)if(b[i]>max)max=b[i];
        n-=max;
        br++;
    }
    while(n!=0);
    cout<<br<<endl;
    system("pause");
    return 0;
}
