#include <iostream>

using namespace std;

long long int n, ost, rez;

int main(){
	cin >> n;
	while(n > 0){
		ost = n%10;
		n/=10;
		rez+= ost/5;
		ost = ost%5;
		rez+= ost/2;
		ost = ost%2;
		rez+= ost/1;
		ost = ost%1;
	}
	cout << rez << endl;
}