#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli a,cvp;

int main(){
	#ifndef ONLINE_JUDGE
		freopen("zgir.gir","r",stdin);
		freopen("zcik.cik","w",stdout);
	#endif

	cin>>a;
	for(int i=1;i<=a;i++){
		if(i%3!=0 && i%5!=0){
			cvp+=i;
		}
	}
	cout<<cvp;
}