#include <bits/stdc++.h>

int digits(long long n)
{
	int d = 0;
	while(n > 0)
	{
		n /= 10;
		d++;
	}
	return d;
}

int main()
{
	long long v;
	scanf("%lld", &v);
	int d = digits(v);
	
	long long coins[3*d];
	coins[0] = 1; coins[1] = 2; coins[2] = 5;
	for(int i = 3; i < 3 * d; i++)
		coins[i] = coins[i - 3] * 10;
		
	long long k = 0;
	for(int i = 3 * d - 1; i >= 0; i--)
	{
		if(v <= 0) break;
		double c = floor((double)v / coins[i]);
		if(c >= 1e-9 && c <= 1e9)
		{
			v -= coins[i] * (long long)c;
			k += (long long)c;
		}
	}
	printf("%lld", k);
}