#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
int v, br, i, n, r=1;
long long pet=5000000000, dva=2000000000, jedan=1000000000;
br=0;
n=30;
vector<long long> novci(n);
cin>>v;
for(i=0;i<n; i=i+3)
{
 novci[i]=pet/r;
 novci[i+1]=dva/r;
 novci[i+2]=jedan/r;
	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;
}