#include <stdio.h>
#include <stdlib.h>

int intPow( int b, int p )
{
    int t = b;

    if( p == 0 )
        return 1;
    else if ( p == 1 )
        return b;
    else
    {
        while( p > 1 )
        {
            t = t * b;
            p--;
        }
        return t;
    }
}

int maxN( int x )
{
    int nMax = 1;
    int pMax = 1;
    int i = 0;
    int j = 0;
    int d[3] = {1,2,5};

    while( 1 )
    {
        if ( i == 3 )
            i = 0;

        int t = d[i] * intPow( 10, j / 3 );

        if ( t > x )
        {
            break;
        }

        i++;
        j++;

        pMax = t;
    }

    return pMax;
}

int main()
{
    int x;
    int n = 0;

    scanf("%d", &x);

    while ( x > 0 )
    {
        int max = maxN(x);
        x -= max;
        n++;
    }

    printf("%d", n);

    return 0;
}