#include <stdio.h>
#include <math.h>

int Cifre (long long int V)
    {
        int n;
        while (V!=0)
            {
                V=V/10;
                n=n+1;
            }
        return n;
    }

int main()
    {
        int k, br=0;
        long long int V, x;
        scanf("%lli", &V);
        x=V;
        k=Cifre(x);
        while (x!=0)
            {
                k=k-1;
                while(x>=(5*(pow(10, k)))) {x=x-(5*(pow(10, k))); br=br+1;}
                while(x>=(2*(pow(10, k)))) {x=x-(2*(pow(10, k))); br=br+1;}
                while(x>=(1*(pow(10, k)))) {x=x-(1*(pow(10, k))); br=br+1;}
            }
        printf("%d", br);
        return 0;
    }