using System;
using static System.Console;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int sum = 0;
            for(int i = 0; i < N; i ++)
            {
                if(i % 3 != 0 && i % 5 != .0)
                {
                    sum += i;
                }
            }
            WriteLine(sum);
        }
    }
}