#include <iostream>
#include <string>
#include <algorithm>
#include <limits>
#include <iomanip>
#include <cmath>

using namespace std;
using std::cin;
using std::cout;

typedef numeric_limits<streamsize> ignore_t;

int main() 
{
	long long int V{};
	int d[]{ 1, 2, 5 };
	int k{};

	scanf("%lld", &V);

	while ((5 * pow(10, k)) < V)
		++k;

	long long int* novcanice = new long long int[3 * (k+1)];

	int ii{};
	
	for (int i{k}; i >= 0; --i)
	{
		for (int j{2}; j >= 0; --j)
		{
			novcanice[ii++] = d[j] * pow(10, i);
		}
	}

	int br_novcanica{};

	while (V != 0) 
	{
		for (int i{}; i <= 3 * (k+1) && V != 0; ++i) 
		{
			if (novcanice[i] <= V) 
			{
				++br_novcanica;
				V = V - novcanice[i];
				break;
			}
		}
	}

	cout << br_novcanica;

	delete[] novcanice;

	cin.clear();
	cin.ignore(ignore_t::max(), '\n');
	cin.get();

	return 0;
}