#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a;
	long long c=0;
	cin >> a;
	vector<int> b(a);
	for (int i = 0;i < a;i++) {
		bool f = false;
		b[i] = i+1;
		if (b[i] % 3 == 0)f = true;
		if (b[i] % 5 == 0)f = true;
		if (!f)c += b[i];
	}
	cout << c;
}
