#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		sum += i;
		if (i % 3 == 0 || i % 5 == 0) {
			ans += i;
		}
	}
	cout << sum - ans << endl;
	return 0;
}
