#include <iostream>

using namespace std;

int jedan (int c, int p, int br, unsigned long long n, int brojac)
{
    p=c*br;
    brojac+=(n/p);
    n%=10;
    return brojac;
}
int dva(int c, int p, int br, unsigned long long n, int brojac)
{
    if(c<=2)
    {
        if(c%2==0)
       {
           p=c*br;
           brojac+=(n/p);
           n%=br;
       }
       else
       {
           p=c*br;
           brojac+=(n/p);
           n%=br;
           brojac+=jedan(c, p, br, n, 0);
       }
    }
    return brojac;
}
int main()
{
    unsigned long long n, m;
    cin>>n;
    m=n;
    int br=0, brojac=0, c, lenght=0, lenght1, p;
    while(m>0)
    {
        m/=10;
        lenght1++;
    }
    while(lenght1>0)
    {
        lenght=lenght1;
        while(lenght>0)
            br*=10;
        c=n/br;
        if(n<=5)
        {
            if(c%5==0)
            {
               p=c*br;
               brojac+=(n/p);
               n%=br;
            }
            else
              brojac+=dva(c, p, br, n, 0);
        }
        if(n<=2)
        {
            if(c%2==0)
            {
               p=c*br;
               brojac+=(n/p);
               n%=br;
            }
            else
              brojac+=jedan(c, p, br, n, 0);
        }
        if(n<=5)
        {
            p=c*br;
            brojac+=(n/p);
            n%=br;
        }
        br=0;
        lenght1-=1;
        lenght-=1;
        br=0;
    }
    cout<<brojac<<endl;
}