#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
#define ll long long int

int main(){
  int N;
  cin>>N;
  ll count=0;
  rep(i,N){
    if(i%3==0||i%5==0){}
      
    else
      count+=i;

  }
  cout<<count;
  return 0;
}
