#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  ll result = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      result += i;
    }
  }
  cout << result << endl;
  return 0;
}