#include <iostream>
#include <math.h>
using namespace std;
int brcif(long long n){
	int br=0;
	while(n>0){
		n/=10;
		br++;
	}
	return br;
}
int main(){
	long long s;
	int br=0,s1;
	cin>>s;
	while(s!=0){
		if(s<10)s1=s;
		else s1=s/(pow(10,brcif(s)-1));
		//cout<<s1<<endl;
		switch(s1){
			case 1:
				s-=pow(10,brcif(s)-1);
				br++;
				break;
			case 2:
			case 3:
			case 4:
				s-=2*pow(10,brcif(s)-1);
				br++;
				break;
			default:
				s-=5*pow(10,brcif(s)-1);
				br++;
				break;
		}
	}
	cout<<br;
}