#include <iostream>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long c=0;
    int tc;
    while(n>0)
    {
        tc=n%10;
        c+=tc/5;
        tc=tc%5;
        c+=tc/2;
        tc=tc%2;
        c+=tc/1;
        n=n/10;
    }
    cout << c;
}