#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e4+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];

int p ,n;
int val[MAX];

int vis[(1<<16)][16][16];
int  mx;
ll arr[MAX];
int prime[10]={2, 3, 5, 7, 11, 13, 17, 19};
int coun(int x){
	return __builtin_popcount(x);
}

int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	
	cin>>n;
	long long sum=0;
	for(long long i=1;i<=n;i++){
		if((i%3!=0)&&(i%5!=0))
			sum=sum+i;
	}
	cout<<sum;

}