print((sum(set(i for i in range(1,int(eval(input()))+1,1) if not(i%3==0 or i%5==0)))))
print((sum((i for i in range(int(eval(input()))+1) if i%3 and i%5))))
print(
    (
        sum(
            set(
                i
                for i in range(1, int(eval(input())) + 1, 1)
                if not (i % 3 == 0 or i % 5 == 0)
            )
        )
    )
)

print((sum((i for i in range(int(eval(input())) + 1) if i % 3 and i % 5))))

-print( -    ( -        sum( -            set( -                i -                for i in range(1, int(eval(input())) + 1, 1) -                if not (i % 3 == 0 or i % 5 == 0) -            ) -        ) -    ) -) +print((sum((i for i in range(int(eval(input())) + 1) if i % 3 and i % 5))))