#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	typedef long long ll;
	ll n,ans;
	void solve(){
		scanf("%lld",&n);
		for(ll i=1;i<=n;++i)if(i%3&&i%5)ans+=i;
		printf("%lld",ans);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}