#include <iostream>
#include<math.h>
using namespace std;
int main()
{
	int i,v,n=0,k,brnov=0,prom,prvacifra;
	float j=10;
	cin>>v;
	prom=v;
	while(prom>0) prom=prom/10,n+=1;
	k=n-1;
	for(i=0;i<n;i++)
	{
		if(i=n-1)prvacifra=v%10;
		else prvacifra=v/10;
		switch(prvacifra){
		case 1:v=v-pow(j, k);brnov+=1;break;
		case 2:v=v-2*pow(j, k);brnov+=1;break;
		case 3:v=v-3*pow(j, k);brnov+=2;break;
		case 4:v=v-4*pow(j, k);brnov+=2;break;
		case 5:v=v-5*pow(j, k);brnov+=1;break;
		case 6:v=v-6*pow(j, k);brnov+=2;break;
		case 7:v=v-7*pow(j, k);brnov+=2;break;
		case 8:v=v-8*pow(j, k);brnov+=3;break;
		case 9:v=v-9*pow(j, k);brnov+=3;break;
		}
		k-=1;
	
	}
	cout<<brnov;

return 0;
}