n=int(eval(input()))

n=list(range(1,n+1))

n=([i for i in n if i % 3 != 0])

n=([i for i in n if i % 5 != 0])

print((sum(n)))
n=int(eval(input()))

n=list(range(1,n+1))

n=([i for i in n if i % 3 != 0 and i % 5 != 0])

print((sum(n)))

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

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

-n = [i for i in n if i % 3 != 0] -n = [i for i in n if i % 5 != 0] +n = [i for i in n if i % 3 != 0 and i % 5 != 0]