#include <iostream>
#include <algorithm>
using namespace std;
int stepen(int stepen1){
    int c1=1;
    for(int i=0;i<stepen1;++i){
        c1*=10;
    }
    return c1;
}
int main(){
    int v,niz[50000],br=0,krbr=0,ij=1;
    cin>>v;
    int v1=v;
    while(v1>0){
        v1/=10;
        ++br;
    }
    niz[0]=1;
    niz[1]=2;
    niz[2]=5;
    int br1=3;
    for(int i=1;i<=br-1;++i){
        for(int j=0;j<3;++j){
            niz[br1]=niz[j]*stepen(i);
            //cout<<niz[br1]<<endl;
            ++br1;
        }
    }
    
    while(v>1){
    	if(v>=niz[br1-ij]){
    		//cout<<"2"<<endl;
    		krbr+=v/niz[br1-ij];
    		//cout<<v<<" "<<niz[br1-ij]<<endl;
    		v=v%niz[br1-ij];
    		//cout<<v<<" "<<krbr<<endl;
		}
		else{
			//cout<<"1"<<endl;
			ij++;

		}
	}
	cout<<krbr;
    //cout<<stepen(3)<<endl;
    /*for(int i=0;i<br1;++i){
        while(v)
    }*/
    /*if(v%niz[br1-ij]==0){
        cout<<"1";
        return 0;
    }*/
    //cout<<niz[5]<<endl;
    //cout<<br1<<endl;
    //cout<<v/niz[br1-ij];
    /*while(v>0){
    	//cout<<" dsdasdsadasd111";
        if(v>niz[br1-ij]>0){
            krbr=v/niz[br1-ij];
            v=v%niz[br1-ij];
            --ij;
            cout<<"jej";
        }
        else{
        	while(v<niz[br1-ij]){
        		ij=ij-1;
        		cout<<"xejex";
			}
        }
        //cout<<krbr<<endl;
    }*/
    //cout<<" "<<" "<<niz[br1-ij]<<" "<<v<<" "<<v%niz[br1-ij]<<endl;
    /*while(v>0){
    	/*if(v<niz[br1-ij]){
    		while(v<niz[br1-ij]){
    			ij--;
			}
		}
    	krbr+=v/niz[br1-ij];
    	v=v%niz[br1-ij];
    	ij--;
    	cout<<"jabdabdiua"<<endl;
	}*/
	/*for(int i=0;i<br1;++i){
		in
	}*/
	//int e=br1;
	/*for(int i=0;i<50000;++i){
		cout<<"9"<<endl;
		if(v==0){
			break;
		}
		if(v>niz[br1-ij]){
			krbr+=v/niz[br1-ij];
			v=v%niz[br1-ij];
		}
		
		else{
			ij--;
		}
		
	}*/
	//cout<<krbr;	
	//cout<<"audaiudia"<<endl;
    //cout<<krbr;
    /*for(int i=0;i<br1;++i){
    	cout<<niz[i]<<" ";
	}*/
	
    return 0;
}