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

vector <long long> v;
long long i,pom=1,t,cnt;
 
int main()
{
    srand(time(NULL));
    std::ios_base::sync_with_stdio(false);
    for(i=0;i<19;i++){
        if(pom<=M) v.push_back(pom);
        if(2*pom<=M) v.push_back(2*pom);
        if(5*pom<=M) v.push_back(5*pom);
        pom*=10;
    }
    reverse(v.begin(),v.end());
    cin>>t;
    for(i=0;i<v.size();i++){
        if(v[i]<=t){
            t-=v[i];
            cnt++;
            i--;
        }
    }
    cout<<cnt<<endl;
    return 0;
}