/*
TASK:sub
LANG: C++

*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;

 
int main()
{
 int n,x,max4n=0,br=0;
 cin>>n;
 do
 {x=n;
  do
  {
   if(max4n<x%10)max4n=x%10;
   x=x/10;
  }while(x>0);
  n=n-max4n;
  br++;max4n=0;
 }
 while(n!=0);
 cout<<br<<"\n";


return 0;
}
