#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll n;
  cin >> n;

  ll ans = 0;
  REP(i, n) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    else
      ans += i;
  }

  cout << ans << "\n";
}