#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	int temp1 = n / 15;
	int temp2 = n / 5;
	int temp3 = n / 3;
	ll ans = 0;

	for(int i=1; i<=n; i++) {
		if(i % 3 == 0) continue;
		if(i%5 == 0)continue;
		if(i%15==0) continue;
		ans += i;
	}

	cout << ans << endl;

  return 0;
}