#include <iostream>
using namespace std;
long long int typedef ll;

int main()
{
	int br = 0,krug = 0;
	ll V; cin >> V;
	ll z = 1000000000000;
	while (V>0)
	{
		if (z <= V)
		{
			br += V / z;
			V %= z;
		}
		if (krug == 0)
		{
			z /= 2;
			krug++;
		}
		else if (krug == 1)
		{
			z = z / 5 * 2;
			krug++;
		}
		else
		{
			z /= 2;
			krug = 0;
		}
	}
	cout << br;
    return 0;
}