#include <bits/stdc++.h>
#include <map>
#include <vector>


using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    unsigned long long n;
    map<int, int> comp;
    int i, sum = 0, k, b;
    int a[3] = {5,2,1};
    scanf("%llu",&n);
    while(n != 0){
        int s = n % 10;
        b = s;
        i = 0;
        k = 0;
        auto it = comp.find(s);
        if(it != comp.end()){
            sum += it->second;
        }else{
            while(s != 0){
                sum += s / a[i];
                k += s / a[i];
                s = s % a[i];
                i++;
            }
            comp.insert(pair<int, int>(b, k));

        }
        n = n / 10;

    }
    printf("%d", sum);
}