#include<iostream>

using namespace::std;

int main()
{
	long long V;
	cin >> V;
	int b = 0,k;
	while (V != 0)
	{
		k = V % 10;
		while (k != 0)
		{
			if (k >= 5)
			{
				b++;
				k -= 5;
			}
			else if (k >= 2)
			{
				b++;
				k -= 2;
			}
			else if (k >= 1)
			{
				b++;
				k -= 1;
			}
		}
		V /= 10;
	}
	cout << b;
}