//Failure will never overtake me if my determination to succeed is strong enough
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n;
    cin >> n;
    int k = 18;
    long long d[3];
    d[0] = 1;
    d[1] = 2;
    d[2] = 5;

    int rez = 0;
    while(k-- && n > 0)
    {
        while(n >= d[2]*pow(10, k))
        {
            n -= d[2]*pow(10, k);
            rez++;
        }

        while(n >= d[1]*pow(10, k))
        {
            n -= d[1]*pow(10, k);
            rez++;
        }

        while(n >= d[0]*pow(10, k))
        {
            n -= d[0]*pow(10, k);
            rez++;
        }

    }

    cout << rez;
}