#include <iostream>
#include <cmath>

int eh(long long a) {
	int l, t;
	l = int(log10(a));
	t = a / pow(10, l);
	a -= t * pow(10, l);
	switch (t) {
	case 1:
		return (1 + eh(a));
		break;
	case 2:
		return (1 + eh(a));
		break;
	case 5:
		return (1 + eh(a));
		break;
	case 3:
		return (2 + eh(a));
		break;
	case 4:
		return (2 + eh(a));
		break;
	case 6:
		return (2 + eh(a));
		break;
	case 7:
		return (2 + eh(a));
		break;
	case 8:
		return (3 + eh(a));
		break;
	case 9:
		return (3 + eh(a));
		break;
	}
	return 0;
}

int main() {
	long long a;
	std::cin >> a;
	std::cout << eh(a);
	return 0;
}