#include <iostream>
using namespace std;

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