#include<iostream>
using namespace std;

int main()
{
    long long int V;
    cin >> V;

    int n = 0, c;
    while(V>0)
    {
        c = V % 10;
        n += c / 5;
        c %= 5;
        n += c / 2;
        c %= 2;
        n += c;

        V /= 10;
    }

    cout << n;

    return 0;
}