#include <stdio.h>
#include <math.h>

int main() {

	unsigned long v, num;
	scanf(" %ld", &v);

	unsigned long x = v;

	int brc = 0;
	while(x > 0) {
		x /= 10;
		brc++;	
	}

	int novcanice = 0;
	for(int i = brc; i >= 0; i--) {
		num = 5 * pow(10, i);
		novcanice += v / num;
		v %= num;
		
		num = 2 * pow(10, i);
		novcanice += v / num;
		v %= num;

		num = 1 * pow(10, i);
		novcanice += v / num;
		v %= num;
	}
	printf("%d\n", novcanice);

	return 0;
}
#include <stdio.h>
#include <math.h>

int main() {

	unsigned long v, num;
	scanf(" %ld", &v);

	unsigned long x = v;

	int brc = 0;
	while(x > 0) {
		x /= 10;
		brc++;	
	}