using AtCoderStudy.Algorithm;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

	class Program
	{

		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			long answer = 0;

			for(int i = 1; i <= N; i++)
			{
				if(i % 3 != 0 && i % 5 != 0)
				{
					answer += i;
				}
			}

			Console.WriteLine(answer);
		}
	}
}