#include <iostream>

int main()
{
	unsigned long long d[] = {1, 2, 5, 10};
	unsigned long long v;
	int br = 0;
	scanf("%llu", &v);
	if(v==10000000000000000000)
	{
		printf("1");
		return 0;
	}
	for(unsigned long long deset = 10000000000000000000;deset>0;deset/=10)
	{
		if(deset<=v)
		{
			for(int i = 2;i>=0;i--)
			{
			
				if(d[i]*deset<=v)
				{
					v-=d[i++]*deset;
					br++;
				}
					
			}
		}
	}
	printf("%llu", br);
	return 0;
}