#include <sstream>
#include <fstream>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <cstdio>


#include <stdlib.h>
#include <iostream>
#include <chrono> //clock
#include <vector>
#include <string>
#include <iomanip>  //setprecision function
#include <cmath>	//math
#include <cstdio>
#include <vector>	//vector array
#include <algorithm>	//STL algorithm
#include <set> //STL library set
#include <sstream> // for stringstream


using namespace std;
using namespace std::chrono; 

int main() {
	stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	
	int N;
	cin>>N;
	int sum=0;
	for(int i=1;i<=N;i++){
		if(i%3!=0 and i%5!=0) sum+=i;
	}

	cout<<sum<<endl;
	
		
	return 0;
}



























