#include <bits/stdc++.h>

using namespace std;

string v;
long long nov;
int cif;

int main()
{
    cin >> v;
    for (int i = 0; i < v.size(); ++i)
    {
        cif = v[i]-'0';
        nov += cif/5;
        cif = cif % 5;
        if (cif > 0)
        {
            nov += cif/2 + cif % 2;
        }
    }
    cout << nov << endl;
    return 0;
}