#include<bits/stdc++.h>

using namespace std;

int main()
{
	long long n, ans = 0, k, d, m = 0;
	cin >> n;
	while(n > 0)
	{
		m = n % 10, n /= 10;
		if(m >= 5) m %= 5, ++ans;
		if(m >= 2) ans += m / 2, m = m % 2;
		if(m == 1) ++ans;
	}
	cout << ans;
	return 0;
}