#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;


int main() {
  ll n; cin >> n;
  ll s = 0;
  rep(i,n) {
    if (i%3 == 0 || i%5 == 0) {
      continue;
      s += i;
    }else {
      s += i;
    }
  }
  cout << s << endl;
  return 0;
  
}
 