def main():
    A = map(int, input().split())

    wc = 0
    for i in A:
        if not i % 15:
            wc += 8
        elif not i % 3 or not i % 5:
            wc += 4
        else:
            wc += len(str(i))
    print(wc)

main()