#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long int stepen(long long int x)
{
    long long int k;
    k=1;
    for (int i=5;i++;){
        if (k>x) {
            k=k/10;
            return k;}
        else {k=k*10;}}
}
int main()
{
    long long int cena, trstepen, trsmanjenje, trcena, rez;
    rez=0;
    cin >> cena;
    trcena=cena;
    while (trcena>0)
    {
      if((trcena-5*stepen(trcena))>=0) {
            trcena=trcena-5*stepen(trcena);rez++;continue;
            }
      else if(trcena-2*stepen(trcena)>=0) {trcena=trcena-2*stepen(trcena);rez++; continue;}
      else {trcena=trcena-1*stepen(trcena);rez++; continue;}
    }
    cout << rez;
    return 0;
}