#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> nn(n);
  rep(i, n) nn[i] = i + 1;

  ll res = 0;
  for (int nnn : nn) {
    if (nnn % 3 == 0 && nnn % 5 == 0) {
    } else if (nnn % 3 == 0) {
    } else if (nnn % 5 == 0) {
    } else {
      res += nnn;
    }
  }
  cout << res << endl;

  return 0;
}
