

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main(){
  ll N;
  cin >> N;

  ll sum = 0;
  for(ll i=1; i<N+1; i++){
    if((i%3==0) || (i%5==0)){
      continue;
    }
    sum += i;
  }
  cout << sum << endl;
}