#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>

#define rep(i,n) for(int (i) = 0;(i)<(n);(i)++)

using namespace std;
using p = pair<int, int>;
using ll = long long;

vector< vector<int> > memo;

int main() {
	int n;
	ll ans = 0;
	cin >> n;
	rep(i, n) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans << endl;
	return 0;
}
