#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
#define s second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"	
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (int)1e6+2
using namespace std;
// look for  all edge cases
//bool seq[nax] = {false};


int main(){
	fast;
	int n ;
	cin >> n;
	ll sum = 0;
	for(int i = 1 ; i<= n; i++){
		if(i%3 == 0){
		}	
		else if(i%5 == 0){
		}
		else{
			ll temp = i;
			sum += temp;
		}
			
		
	}
	cout<<sum;
	return 0;
	
}
