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

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

    scanf("%lld", &x);

    while(x)
    {
        tmp=x%10;
        br+=tmp/5;
        tmp%=5;
        br+=tmp/2;
        tmp%=2;
        br+=tmp;
        x/=10;
    }

    printf("%lld", br);

    return 0;
}