A = list(map(int,input().split())) ret = 0 for a in A: if a%15==0: ret += 8 elif a%5==0 or a%3==0: ret += 4 else: ret += len(str(a)) print(ret)