#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k;
	vector<long long> v;
	int i=3;
	cin>>k;
	int br=1;
	v.push_back(1);
	v.push_back(2);
	v.push_back(5);
	v.push_back(-1);
	while(v[i]<k)
	{
		v.push_back(pow(10, br));
		v.push_back(2*pow(10, br));
		v.push_back(5*pow(10, br));
		br++;
		i+=3;
	}
	v.erase(v.begin()+3);
	int x=0;
	int p=i;
	while(k>0){
		if(k>=v[p]){
			x+=k/v[p];
			k=k%v[p];
		}
		p--;
	}
	cout<<x<<endl;
	return 0;
}