#include <iostream>
using namespace std;

int main()
{
    int v;
    int ost;
    int br = 0;

    cin >> v;

    while(v != 0)
    {
        ost = v%10;
        while(ost > 5)
        {
            ost -= 5;
            br++;
        }

        while(ost > 2)
        {
            ost -= 2;
            br++;
        }

        while(ost > 1)
        {
            ost -= 1;
            br++;
        }

        v /= 10;
    }
    
    cout << br;

	return 0;
}