N = int(eval(input()))

none_num = [i for i in range(1, N+1) if i%3 != 0 and i%5 != 0]

none = sum(none_num)

print(none)
K = int(eval(input()))

x = (K+1) * K//2

num_devisible_three = (3+3*(K//3))*(K//3)//2

num_devisible_five = (5+5*(K//5))*(K//5)//2

num_devisible_fifteen = (15+15*(K//15))*(K//15)//2

print((x-num_devisible_three-num_devisible_five+num_devisible_fifteen))
N = int(eval(input()))
none_num = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0]
none = sum(none_num)
print(none)

K = int(eval(input()))
x = (K + 1) * K // 2
num_devisible_three = (3 + 3 * (K // 3)) * (K // 3) // 2
num_devisible_five = (5 + 5 * (K // 5)) * (K // 5) // 2
num_devisible_fifteen = (15 + 15 * (K // 15)) * (K // 15) // 2
print((x - num_devisible_three - num_devisible_five + num_devisible_fifteen))

-N = int(eval(input())) -none_num = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0] -none = sum(none_num) -print(none) +K = int(eval(input())) +x = (K + 1) * K // 2 +num_devisible_three = (3 + 3 * (K // 3)) * (K // 3) // 2 +num_devisible_five = (5 + 5 * (K // 5)) * (K // 5) // 2 +num_devisible_fifteen = (15 + 15 * (K // 15)) * (K // 15) // 2 +print((x - num_devisible_three - num_devisible_five + num_devisible_fifteen))