#include<bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{
	ll v,t,m,ans=0;
	cin >> v;
	while(v>0)
	{
		t = log10(v);
		m=v/(5*pow(10,t));
		ans+=m;
		v-=m*5*pow(10,t);
		m=v/(2*pow(10,t));
		ans+=m;
		v-=m*2*pow(10,t);
		m=v/pow(10,t);
		ans+=m;
		v-=m*pow(10,t);
	}
	cout<<ans;
}