import java.util.Scanner; public class No637 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a[] = new int[5]; int sum = 0; for(int i = 0;i < 5;i++) { a[i] = sc.nextInt(); if(a[i] % 15 == 0) { sum += 8; }else if(a[i] % 3 == 0 ||a[i] % 5 == 0) { sum += 4; }else { sum += String.valueOf(a[i]).length(); } } System.out.println(sum); } }