#include <iostream>

using namespace std;

#define MAX 1e18
int d[3] = {5, 2, 1};

auto main() -> int
{
    long long n, sol=0; cin >> n;
    for(long long a=MAX; a>0; a/=10)
        for(int i=0; i<3; i++)
            sol += n/(d[i]*a),
            n %= d[i]*a;
    cout << sol; return 0;
}