#include<bits/stdc++.h>
using namespace std;
bool pertence_sequence(int i) { return ((i % 3 == 0) || (i % 5 == 0)); }
int main() {
	long long a, sum;
	while(cin >> a) {
		sum = 0;
		for(int i = 1; i <= a; i++) {
			if(!pertence_sequence(i)) {
				sum += i;
			}
		}
		cout << sum << endl;
	}
	return 0;	
}
