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

void Main() {
	int N;
	int total = 0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		total += i;
	}
	cout << total << endl;
}

int main() {
	Main();
}