# No.637 X: Yet Another FizzBuzz Problem a = [int(i) for i in input().split()] num = 0 for w in a: if w % 3 == 0 and w % 5 == 0: num += 8 elif w % 3 == 0 or w % 5 == 0: num += 4 else: num += len(str(w)) print(num)