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

constexpr int MAXN = 1e3 + 3;
constexpr double down = 0.996;

int n;
long long sum;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		sum += i;
	}
	cout << sum << endl;
    return 0;
}