#include<bits/stdc++.h>

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long n, s = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) s += i;	
	}
	cout << s << '\n';
	return 0;
}