import java.util.Scanner; public class No637 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int[]a=new int[5]; for(int i=0;i<5;i++) a[i]=Integer.parseInt(sc.next()); System.out.println(getNum(a)); } public static int getNum(int[] a) { int x=0; for(int i=0;i<5;i++) if((a[i]%3==0)&&(a[i]%5==0)) x=x+8; else if(a[i]%3==0) x=x+4; else if(a[i]%5==0) x=x+4; else { String b=Integer.toString(a[i]); x=x+b.length(); } return x; } }