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

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

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