#include <iostream>
#include<math.h>
using namespace std;
int novcanica(int v) {
	int x, y, k = 0;
	while (1) {
		k++;
		for (int d = 1; d <= 5; d += 2) {
			y = d * pow(10, k);
			if (y <= v)x = y; else break;
		}
	}return x;
}
int main() {
	int v, z = 0;
	cin >> v;
	while (v>0) {
		v -= novcanica(v);
		z++;
	}
	cout << z;
	return 0;
}