#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;

	long long ll = 0;

	while(n != 0) {
		if(n % 3 == 0 || n % 5 == 0) {
		} else {
			ll += n;
		}
		n--;
	}

	cout << ll << endl;

    return 0;
}
