#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	long long n,ans=0;
	cin>>n;
	for (long long i=1;i<=n;i++){
		if (i%3!=0 && i%5!=0){
			ans+=i;
		}
	}
	cout<<ans;
	re 0;
}