#include <iostream>
using namespace std;
#define p printf
#define s scanf
#define REP(i, a, b) for(int i = 1; i<=n; i++)
int main()
{
	int n; cin >> n;
	long long int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && (i % 5 != 0))
		{
			sum = sum + i;
		}
	}
	cout << sum << "\n";
}
