#include <stdio.h>
#include <stdlib.h>


 unsigned long long stepen(unsigned long long m, unsigned long long n){
 	if (n == 0)
 	return 1;
 	unsigned long long x = m;
 	unsigned long long i = 1;
 	for (i; i<n; i++)
 	x*=m;
 	return x;
 }


int main() {
	unsigned long long v;
	scanf("%lld", &v);
	unsigned long long x = 0;
	unsigned long long a[100];
	unsigned long long i = 0;
	a[0] = 1;
	int d = 1, k = 0;
	while (a[i++] <= v) {
		
		if (d == 1)
		d = 2;
		else if (d == 2)
		d = 5;
		else if (d == 5) {
			d = 1;
			k++;
		}
		a[i] = d * stepen (10, k);
	}
	i--;
	while (v) {
		while (v>=a[i]) {
			v-=a[i];
			x++;
		}
		i--;
	}
	printf("%lld", x);
	return 0;	
}