List = list(map(int,input().split())) lett = "" count = 0 for i in range(5): if List[i]%5 == 0 and List[i]%3 ==0: count = count + 8 elif List[i]%5 == 0 or List[i]%3 == 0: count = count + 4 else: count = count + len(str(List[i])) print(count)