# coding: utf-8 A = list(map(int,input().split(" "))) c = 0 for a in A: if a % 3 == 0 and a % 5 == 0: c += 8 elif a % 3 == 0 or a % 5 == 0: c += 4 else: c += len(str(a)) print(c)