#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    unsigned long long n;
    int i, sum = 0;
    int a[3] = {5,2,1};

    scanf("%llu",&n);
    while(n != 0){
        int s = n % 10;
        i = 0;
        while(s != 0){
            sum += s / a[i];
            s = s % a[i];
            i++;
        }
        n = n / 10;
    }
    printf("%d", sum);
}