#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;	
		


int32_t main()
{   
	IOS
	int n;cin>>n;
	//int _5 = n/5;
	//int _3 = n/3;
	//int _15 = n/15;
	//cout << n*(n+1)/2 - _5*(2*5+(_5-1)*5)/2 - _3*(2*3+(_3-1)*3)/2 + _15*(2*15-(_15-1)*15)/2 <<endl;
	int sum = 0;
	for(int i=1;i<=n;i++){
		if( i%5==0 || i%3==0 )continue;
		sum+=i;
	}
	cout<<sum<<endl;
}



