#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
int main()
{
int v, br, i, n, q=1, r=1;
br=0;
n=30;
vector<unsigned> novci(n);
cin>>v;
for(i=0;i<n; i++)
{
	if(q==1) novci[i]=5000000000/r;
	if(q==2) novci[i]=2000000000/r;
	if(q==3) novci[i]=1000000000/r;
	q++;
	if(q>3) q=1;
	r=r*10;
}
	for(i=0;i<n; i++)
	{
		if(v>=novci[i])
		{
			br=br+(v/novci[i]);
			v=v-(novci[i]*(v/novci[i]));
		}
	}
cout<<br;
system("pause");
return 0;
}