#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		long long ans = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0) continue;
			if (i % 5 == 0) continue;
			ans += i;
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}