A = list(map(int,input().split())) answer = 0 for i in range(5) : if A[i] % 3 != 0 and A[i] % 5 != 0 : answer += len(str(A[i])) elif A[i] % 15 == 0 : answer += 8 else : answer += 4 print(answer)