#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, zbir=0, cif;
    cin >> n;
    while(n!=0)
    {
        cif=n%10;
        zbir+=cif/5+(cif%5)/2+(cif%5)%2;
        n=n/10;
    }
    cout << zbir;
    return 0;
}