using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_162
{
    class B
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            long n = long.Parse(input1);

            long n3 = n / 3;
            long n5 = n / 5;
            long n15 = n / 15;
            long sum = (n * (2 * 1 + (n - 1)) / 2) - (n3 * (6 + (n3 - 1) * 3) / 2) - (n5 * (10 + (n5 - 1) * 5) / 2) + (n15 * (30 + (n15 - 1) * 15) / 2);

            Console.WriteLine(sum);
        }
    }
}
