import java.io.*; import java.util.*; public class Main_yukicoder637 { private static Scanner sc; private static Printer pr; private static void solve() { int ans = 0; for (int i = 0; i < 5; i++) { int a = sc.nextInt(); if (a % 3 == 0 && a % 5 == 0) { ans += 8; } else if (a % 3 == 0 || a % 5 == 0) { ans += 4; } else { ans += Integer.toString(a).length(); } } pr.println(ans); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }