#include <iostream>
#include <string>
using namespace std;

string v;
int sol = 0;

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