ls = list(map(int,input().split())) c = 0 for i in ls: if i % 3 == 0: c += 4 if i % 5 == 0: c += 4 if i % 3 != 0 and i % 5 != 0: c += len(str(i)) print(c)