#include <bits/stdc++.h>
 
using namespace std;

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL n;
	cin >> n;

	LL cnt = 0;
	LL sum = 0;
	LL i = 1;
	while (i < n) {
		
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
		i++;
	}
	cout << sum << "\n";
}