#include<bits/stdc++.h>

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define ll long long

using namespace std;

int main(){
  ll N;
  cin >> N;
  ll sum=0;
  rep(i,N){
    if((i+1)%3!=0&&(i+1)%5!=0){
      sum+=i+1;
    }
  }
  cout << sum;
  return 0;
}
