#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	ll sum = 0;
	for (int ii = 1; ii <= N; ++ii){
		if ( ((ii % 3) != 0) && ((ii % 5) != 0) ){
			sum += ii;
		}
	}

	cout << sum << endl;

	return 0;
}
