#include <iostream>

using namespace std;

int main()
{
	unsigned long long v;
	cin >> v;
	unsigned long long v1=v,a=1,b=2,c=5;
	int br2=0,br=0;
	while(v1>0)
	{
		br++;
		v1=v1/10;
		a=a*10;
		b=b*10;
		c=c*10;
	}
	while(v>0)
	{
		br2+=v/c;
		v=v%c;
		br2+=v/b;
		v=v%b;
		br2+=v/a;
		v=v%a;
		a=a/10;
		b=b/10;
		c=c/10;
	}
	cout << br2;
}