#include <bits/stdc++.h>

using namespace std;


int main() {
    long long int V, novc = 0;
    cin >> V;
    while(V > 0)
    {
        if(V % 10 >= 5)
        {
            V = V - 5;
            novc++;
        }
        while(V % 10 >= 2)
        {
            V = V - 2;
            novc++;
        }
        if(V % 10 == 1)
        {
            V = V - 1;
            novc++;
        }
        V = V / 10;
    }
    cout << novc;
    
}