import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(),s1=0,s2=2,t[]=new int[10]; sc.close(); do { s1++; s2++; t[n%10]++; n/=10; }while(n>0) ; s1*=2; s1++; s1+=t[0]; s1+=t[4]; s1+=t[6]; s1+=t[8]*2; s1+=t[9]; s2+=t[0]*2; s2+=t[4]*2; s2+=t[6]*2; s2+=t[8]*4; s2+=t[9]*2; if(s1>s2) System.out.print(s2); else System.out.print(s1); } }