#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		main(void){
	ll sum;
	ll	n;
	ll  i;

	cin >> n;
	sum = 0;
	i = 0;
	while (i <= n)
	{
		if (i % 3 && i % 5)
			sum += i;
		i++;
	}
	cout << sum << endl;
}
