import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int[] a = new int[5]; for (int i = 0; i < a.length; ++i) a[i] = sc.nextInt(); int ans = 0; for (int v : a) { if (v % 5 == 0 && v % 3 == 0) { ans += 8; } else if (v % 3 == 0) { ans += 4; } else if (v % 5 == 0) { ans += 4; } else { ans += String.valueOf(v).length(); } } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }