def solve(string):

    return str(sum(i for i in range(int(string) + 1) if i % 3 > 0 and i % 5 > 0))





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):

    n = int(string)



    def f(n):

        return n * (n + 1) // 2



    return str(f(n) - 3 * f(n // 3) - 5 * f(n // 5) + 15 * f(n // 15))





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    return str(sum(i for i in range(int(string) + 1) if i % 3 > 0 and i % 5 > 0))


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    n = int(string)

    def f(n):
        return n * (n + 1) // 2

    return str(f(n) - 3 * f(n // 3) - 5 * f(n // 5) + 15 * f(n // 15))


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

-    return str(sum(i for i in range(int(string) + 1) if i % 3 > 0 and i % 5 > 0)) +    n = int(string) + +    def f(n): +        return n * (n + 1) // 2 + +    return str(f(n) - 3 * f(n // 3) - 5 * f(n // 5) + 15 * f(n // 15))