#include<bits/stdc++.h>
using namespace std; 
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
		int n;
		long long sum=0;
  	cin>>n;
  	while(n--){
    	if(n%3==0 || n%5==0);
      else
          sum+=n;
    }
  	cout<<sum;
}