#include <iostream>
using namespace std;

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

	return 0;
}