n = int(eval(input()))



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



print((sum(a)))



# 別解法　o(1)

def gauss(n):

    return n * (n+1) // 2



n = int(eval(input()))

ans =  gauss(n) - gauss(n//3) * 3 - gauss(n//5) * 5 + gauss(n//15) * 15



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

# 別解法　o(1)
def gauss(n):
    return n * (n + 1) // 2


n = int(eval(input()))
ans = gauss(n) - gauss(n // 3) * 3 - gauss(n // 5) * 5 + gauss(n // 15) * 15
print(ans)

+# 別解法　o(1) +def gauss(n): +    return n * (n + 1) // 2 + + -a = [i for i in range(1, n + 1) if i % 3 != 0 and i % 5 != 0] -print((sum(a))) +ans = gauss(n) - gauss(n // 3) * 3 - gauss(n // 5) * 5 + gauss(n // 15) * 15 +print(ans)