#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    unsigned long long x, br=0, tmp;

    scanf("%llu", &x);

    while(x)
    {
        tmp=x%10;

        br+=tmp/5;
        tmp%=5;

        br+=tmp/2;
        tmp%=2;

        br+=tmp;

        x/=10;
    }

    printf("%llu", br);

    return 0;
}