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

    unsigned long long int stepen(int b,int k)
        {
                unsigned long long int s=1;
                for(int i=0;i<k;i++)
                {
                    s*=b;
                }
                return s;

        }
    int brCifara(unsigned long long int v)
        {
            int k = 0;
            while (v > 0)
            {
                v /= 10;
                k++;
            }
            return k;
        }

int main()
{
            ios_base::sync_with_stdio(false);
            unsigned long long int v;
            cin>>v;
            int b=0,k=0,prva;
            k = brCifara(v);
            unsigned long long int d;
            while (v > 0)
            {
                k = brCifara(v);
                prva = v /stepen(10, k-1 );
                if (prva >= 5)
                {
                    d=stepen(10, k-1)*5;
                    b += v / (d);
                    v %= d;
                }
                else if (prva >= 2 && prva < 5)
                {
                    d = 2 * stepen(10, k-1);
                    b += v / d;
                    v %= d;
                }
                else if (prva == 1)
                {
                    d = 1 * stepen(10, k-1);
                    b += v / d;
                    v %= d;
                }

            }
            cout<<b<<endl;
            return 0;
}