#include<bits/stdc++.h>
using namespace std;

int main(){
  long long N;
  cin>>N;
  long long total=0;
  for(int i=1;i<=N;i++){
      if(i%3==0) continue;
      if(i%5==0) continue;
      //cout<<i<<endl;
      total=total+i;
  }
  cout<<total<<endl;
  
  
  return 0;
}

  
  
  
  


 