#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int n;
LL ans;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		if(i % 3 && i % 5) ans += (LL)i;
	}
	cout << ans << endl;
	return 0;
}