#include <iostream>
using namespace std;
typedef unsigned long long  ulli;
int main(){
	ulli v;
	cin >> v;
	ulli niz[54];
	niz[0]=1;niz[1]=2;niz[2]=5;
	for(int i=1; i<18; i++){
		niz[i*3]=niz[(i-1)*3]*10;
		niz[i*3+1]=niz[(i-1)*3+1]*10;
		niz[i*3+2]=niz[(i-1)*3+2]*10;
	}
	int br=0;int i=53;
	while(v>0){
		int k=v/niz[i];
		br+=k;
		v-=k*niz[i];
		i--;
	}
	cout<<br;
	return 0;
}