a = int(eval(input()))

sum = 0

list_number = []

for i in range(a):

    list_number.append(i + 1)

for i in list_number:

    if i % 3 == 0 and i % 5 == 0:

        pass

    elif i % 3 == 0:

        pass

    elif i % 5 == 0:

        pass

    else:

        sum = sum + i

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

sum = 0

for i in range(1, n+1):

    if i % 3 != 0 and i % 5 != 0:

        sum += i

print(sum)

a = int(eval(input()))
sum = 0
list_number = []
for i in range(a):
    list_number.append(i + 1)
for i in list_number:
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        sum = sum + i
print(sum)

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

-a = int(eval(input())) +n = int(eval(input())) -list_number = [] -for i in range(a): -    list_number.append(i + 1) -for i in list_number: -    if i % 3 == 0 and i % 5 == 0: -        pass -    elif i % 3 == 0: -        pass -    elif i % 5 == 0: -        pass -    else: -        sum = sum + i +for i in range(1, n + 1): +    if i % 3 != 0 and i % 5 != 0: +        sum += i