#include <iostream>
#include <math.h>

using namespace std;

unsigned long long int v = 0;
unsigned long long int temp = 0;
int len = 0, bill = 0;

int racunanje()
{
	temp = v;
	while (temp > 0)
	{
		temp /= 10;
		len++;
	}

	if (len == 1)
	{
		if (v > 5)
		{
			bill++;
			v = v - 5;
		}
		if (v == 5 || v == 2 || v == 1)
		{
			bill++;
			v = 0;
			return bill;
		}
		else if (v == 4 || v == 3)
		{
			bill += 2;
			v = 0;
			return bill;
		}
	}

	temp = (v / pow(10, len - 1));
	if (temp == 1)
	{
		bill++;
		v = v - pow(10, len - 1);
		return bill;
	}
	else if (temp <= 4)
	{
		bill++;
		v = v - 2 * pow(10, len - 1);
		return bill;
	}
	else
	{
		bill++;
		v = v - 5 * pow(10, len - 1);
		return bill;
	}
}

int main()
{
	cin >> v;

	while (v > 0)
	{
		bill = racunanje();
		len = 0;
	}
	cout << bill;
}