#include <iostream>
using namespace std;

int main()
{
	long long int n, b, a;
	cin >> n;

	b = 0;
	while (n >= 1) {
		a = n % 10;
		
		if (a >= 5) {
			a = a - 5;
			b+= 1;
		}
		b += a / 2;
		a = a % 2;
		if (a == 1) {
			b+= 1;
		}
		n = n / 10;
		//cout << b << endl;
		//cout << n << endl;
	}
	cout << b << endl;
	return 0;

}