#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<chrono>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
int main()
{

	unsigned long long n = 0;
	cin >> n;

	//3,5,15の倍数を除けば良い

	unsigned long long sum = 0;
	for (unsigned long long i = 0; i < n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)sum += i;
	}
	std::cout << sum << std::endl;


}