#include <bits/stdc++.h>

using namespace std;

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

int main ()
{
    ios_base::sync_with_stdio(false);

    long long v;
    cin>>v;

    int br = 0;
    int k = cif(v);

    int mult = 5;
    long long nov = mult * pow(10,k);

    while(v!=0)
    {
        nov = mult*pow(10,k);
        if(nov<=v)
        {
            br+=v/nov;
            v%=nov;
        }

        switch(mult)
            {
            case 5: mult = 2;break;
            case 2: mult = 1;break;
            case 1: mult = 5;k--;break;
            default:break;
            }
    }
    cout<<br;
    return 0;
}