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

system ("pause");
return 0;
}