import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
		long v=Long.parseLong(br.readLine()); 
		long n=0;
		while(v>0) {
			long k = String.valueOf(v).length();
			int a=(int) (v/Math.pow(10, k-1));
			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;
			}
			v-=a*Math.pow(10, k-1);
		}
		System.out.println(n);	
	}
}