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

int main() {
	unsigned long long sum = 0;
	long long int n;
	cin >> n;
	for(long long int i=1;i<=n;i++){
	    if(i%3!=0&&i%5!=0){
	        sum = sum + i;
	    }
	}
	cout << sum << endl;
	return 0;
}
