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