#include <bits/stdc++.h>


using namespace std;
int main(int argc, char** argv) {
	
	long long int suma;
	cin>>suma;
	long long int zamena = suma;
	int brojac=0;
	int d;
	int k=0;
	long long int a;
	while(suma!=0)
	{
		a=0;
		k=0;
		while(suma >= 10)
		{
			suma/=10;
			k++;
		}
		if(suma == 1)
			d=1;
		if(suma < 5 && suma >= 2)
			d=2;
		if(suma >= 5)
			d=5;
		a=d*pow(10,k);
		zamena = zamena - a;
		suma = zamena;
		brojac++;	
	}
	cout<<brojac;
	return 0;
}