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