using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var sum = 0L;
        for (int i = 0; i < n; ++i)
        {
            if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0)
            {
                continue;
            }

            sum += i + 1;
        }

        Console.WriteLine(sum);
    }
}
