#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll *novcanice;
int d[3];

ll stepen(int x, int y)
{
    if(y == 0) return 1;
    else return x * stepen(x, y - 1);
}

void odredi_novcanice()
{
    ll p;
    int m = 0;
    novcanice = (ll *) malloc(56 * sizeof(ll));
    for(int i = 0; i <= 18; ++i)
    {
        p = stepen(10, i);
        for(int j = 0; j <= 2; ++j)
        {
            novcanice[m] = p * d[j];
            ++m;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    d[0] = 1; d[1] = 2; d[2] = 5;
    odredi_novcanice();

    ll v; cin >> v;
    int br_n = 0, i = 56;
    ll oduzmi;

    while(v > 0)
    {
        oduzmi = novcanice[i];
        while(v >= oduzmi)
        {
            v -= oduzmi;
            ++br_n;
        }
        --i;
    }

    cout << br_n << endl;

    return 0;
}