import java.util.*; class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int[] ar = new int[5]; for (int i=0; i<5; i++) ar[i] = sc.nextInt(); int ans = 0; for (int i=0; i<5; i++) { if (ar[i]%3==0 && ar[i]%5==0) ans += 8; else if (ar[i]%3==0 && ar[i]%5!=0) ans += 4; else if (ar[i]%5==0 && ar[i]%3!=0) ans += 4; else if (ar[i]%3!=0 && ar[i]%5!=0) ans += String.valueOf(ar[i]).length(); } System.out.println(ans); } }