#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    unsigned long long int value;
    cin >> value;
    unsigned short int numberOfBills = 0;
    unsigned long long int tempValue = value;
    unsigned short int counter = 0;
    while(true)
    {

        tempValue/=10;
        counter++;
        if (tempValue == 0)
            break;
    }
    while(value > 0)
    {
        if(value >= 5*pow(10,counter-1))
        {
            value -= 5*pow(10,counter-1);
            numberOfBills++;
        }
        else if(value >= 2*pow(10,counter-1))
        {
            value -= 2*pow(10,counter-1);
            numberOfBills++;
        }
        else if(value >= 1*pow(10,counter-1))
        {
            value -= 1*pow(10,counter-1);
            numberOfBills++;
        }
        else counter--;

    }
    cout << numberOfBills;
    return 0;
}