n = int(eval(input()))

s3 = 0

s5 = 0

s15 = 0

count = 0

for i in range(int(n / 3)):

    s3 += (i+1) * 3

for i in range(int(n / 5)):

    s5 += (i + 1) * 5

for i in range(int(n / 15)):

    s15 += (i + 1) * 15

for i in range(n):

    count += (i+1)

print((count-s3-s5+s15))
n = int(eval(input()))

Sum = 0.5 * n * (1 + n)

# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし

Sum3_5 = 0.5*(int(n/3)*(3+3*int(n/3))+int(n/5)*(5 + 5*int(n/5)))

Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15))

# 問題の回答が整数値のため

print((int(Sum-Sum3_5+Sum15)))
n = int(eval(input()))
s3 = 0
s5 = 0
s15 = 0
count = 0
for i in range(int(n / 3)):
    s3 += (i + 1) * 3
for i in range(int(n / 5)):
    s5 += (i + 1) * 5
for i in range(int(n / 15)):
    s15 += (i + 1) * 15
for i in range(n):
    count += i + 1
print((count - s3 - s5 + s15))

n = int(eval(input()))
Sum = 0.5 * n * (1 + n)
# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし
Sum3_5 = 0.5 * (int(n / 3) * (3 + 3 * int(n / 3)) + int(n / 5) * (5 + 5 * int(n / 5)))
Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15))
# 問題の回答が整数値のため
print((int(Sum - Sum3_5 + Sum15)))

-s3 = 0 -s5 = 0 -s15 = 0 -count = 0 -for i in range(int(n / 3)): -    s3 += (i + 1) * 3 -for i in range(int(n / 5)): -    s5 += (i + 1) * 5 -for i in range(int(n / 15)): -    s15 += (i + 1) * 15 -for i in range(n): -    count += i + 1 -print((count - s3 - s5 + s15)) +Sum = 0.5 * n * (1 + n) +# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし +Sum3_5 = 0.5 * (int(n / 3) * (3 + 3 * int(n / 3)) + int(n / 5) * (5 + 5 * int(n / 5))) +Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15)) +# 問題の回答が整数値のため +print((int(Sum - Sum3_5 + Sum15)))