#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 100005
typedef long long ll;


using namespace std;
ll v,res;
int main()
{
    scanf("%lld",&v);
    ll sd=1;
    for(int i=1;i<=17;i++)sd=sd*10ll;
    for(int i=0;i<=17;i++){
        //printf("%d %lld\n",17-i,sd);
        while(v>=5*sd){
            v-=5*sd;
            res++;
        }
        while(v>=2*sd){
            v-=2*sd;
            res++;
        }
        while(v>=1*sd){
            v-=1*sd;
            res++;
        }
        sd/=10ll;

    }
    printf("%lld",res);
    return 0;
}