import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long v=sc.nextLong();
		long n=0;
		while(v>0) {
			long k = String.valueOf(v).length();
			int b = (int)(v/Math.pow(10, k-1));
			int a=(int)(v/b);
			switch(a) {
			case 1:
			case 2:
			case 5:
				n+=1;
				break;
			case 3:
			case 4:
			case 6:
			case 7:
				n+=2;
				break;
			case 8:
			case 9:
				n+=3;
				break;
			}
			v-=a*b;
		}
		System.out.println(n);	
	}
}