#include <string>
#include <iostream>

int main()
{
	long long V = 0;
	std::cin >> V;
	
	std::string s = std::to_string(V);
	
	int count = 0;
	
	if (V <= 0)
	{
		std::cout << 0;
		
		return 0;
	}
	
	while (V > 0)
	{
		long long temp = std::pow(10, s.length() - 1);
		
		if (s[0] == '1')
			V -= temp;
		else if (s[0] == '2' || s[0] == '3' || s[0] == '4')
			V -= temp * 2;
		else
			V -= temp * 5;
		
		s = std::to_string(V);
		
		++count;
	}
	
	std::cout << count;
	
	return 0;
}