#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	ll n;
	cin>>n;
	ll ans=0;
	//cout<<n<<endl;
	rep(i,n+1){
//		cout<<i<<endl;
		if (i%3==0 or i%5==0) continue;

		ans+=i;
	//	cout<<ans;
	}
	cout<<ans;

}
