#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n, sum = 0, x;
	cin >> n;
	while(n > 0){
		x = n % 10;
		cout << x << "\n";
		n /= 10;
		while(x > 0){
			sum++;
			if(x >= 5)
				x -= 5;
			else if(x >= 2)
				x -= 2;
			else x -= 1;
		}
	}
	cout << sum;

	return 0;
}