print((sum([i for i in range(1, int(eval(input()))+1) if i%3!=0 and i%5!=0])))
n = int(eval(input()))

def s(n):

    return n*(n+1)//2

print((s(n) - s(n//3)*3 - s(n//5)*5 + s(n//15)*15))
print((sum([i for i in range(1, int(eval(input())) + 1) if i % 3 != 0 and i % 5 != 0])))

n = int(eval(input()))


def s(n):
    return n * (n + 1) // 2


print((s(n) - s(n // 3) * 3 - s(n // 5) * 5 + s(n // 15) * 15))

-print((sum([i for i in range(1, int(eval(input())) + 1) if i % 3 != 0 and i % 5 != 0]))) +n = int(eval(input())) + + +def s(n): +    return n * (n + 1) // 2 + + +print((s(n) - s(n // 3) * 3 - s(n // 5) * 5 + s(n // 15) * 15))