#include <iostream>
#include <cmath>
using namespace std;
int main(){
    long long int V, k = 0, brojac = 0, V1;
    int d[3] = {5, 2, 1}, x;
    cin>>V;
    V1 = V;
    while (V1 != 0) {
        V1 /= 10;
        k++;
    }
    k--;
    for(int i = 0;i <= k;i++){
        for(int j = 0;j < 3;j++){
            if(V >= d[j] * pow(10, (k - i))){
                x = V / (d[j] * pow(10, (k - i)));
                V -= x * (d[j] * pow(10, (k - i)));
                brojac += x;
            }
        }
    }
    cout<<brojac;
    return 0;
}