#include<iostream>
#include<vector>
#include<algorithm>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
	int n;cin>>n;
  		ll sum=0;
  rep(i,n){
      if( (i+1)%3==0 || (i+1)%5==0){;}else{sum+=(i+1);} 
         }
  cout<<sum<<endl;
return 0;
}