#include<bits/stdc++.h>
using namespace std;
void solve(){
	size_t n;
	cin>>n;
	size_t ans=0,i;
	for(i=1;i<=n;i++){
		if(i%3==0 || i%5==0)continue;
		ans+=i;
	}
	cout<<ans;
	
}



int main(){
	solve();
}
