#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) (v.begin(),v.end())
#define ff first
#define ss second
const ll maxn=2e5+10;
const ll mod=998244353;


int main() {
  	fast;
  	ll n,flag=0,d,s=0,cnt=0;
  	cin>>n;
  	for(ll i=1;i<=n;i++)
  	{
  		if(i%3!=0 && i%5!=0 && cnt<=n)
  		{
  			cnt++;
  			s+=i;
		}
  			
	}
	
  	cout<<s;
}