#include<iostream>
#include <algorithm>
#include<iomanip>
#include<math.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main()
{
	long long N,plis=0;
	cin >> N;
	for (long long x = 0; x < N; x++)
	{
		if (x % 3 != 0&&  x % 5 != 0)plis += x;

	}
	cout << plis << endl;
		return 0;

}