#include <cstdio>

int smaller10(const int& v)
{
	if (v == 1 || v == 2 || v == 5)
		return 1;
	else if (v == 3 || v == 4 || v == 6
			|| v == 7 || v == 10)
		return 2;
	else return 3;
}

int main()
{
	using u64 = unsigned long long;

	u64 v;
	std::scanf("%llu", &v);

	if (v <= 10)
	{
		std::printf("%d\n", smaller10(v));
		return 0;
	}
	
	int money[12] = {
		1, 2, 5,
		10, 20, 50,
		100, 200, 500,
		100'000, 200'000, 500'000
	};

	int count = 0;
	while (v > 0)
	{
		if (v <= 10)
		{
			count += smaller10(v);
			break;
		}

		int i;
		for (i = 0; money[i] < v; ++i);
		--i;

		while (v >= money[i])
		{
			v -= money[i];
			++count;
		}
	}

	std::printf("%d\n", count);
}