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

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