#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    long long int v;
    int k,z=0;
    cin >> v;
    while(v)
    {
        k=v%10;
        z+=k/5;
        k-=(k/5)*5;
        z+=k/2+k%2;
        v/=10;
    }
    cout << z;

    return 0;
}