#include <iostream>

using namespace std;

int main(){
	long long int V;
	int c,br = 0;
	cin >> V;
	
	while(V){
		c = V % 10;
		if(c >= 5){
			br++;
			c = c - 5;
		}
		while(c >= 2){
			br++;
			c = c - 2;	
		}
		if(c >= 1){
			br++;
		}
		V = V / 10;
	}
	cout << br;
	return 0;
}