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

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int n; cin >> n;
	ll sum = 0LL;
	for (int x = 1; x <= n; x++) {
		if (x % 3 != 0 && x % 5 != 0) {
			sum += x;
		}
	}
	cout << sum << endl;
	return 0;
}
