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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++)
  {
    if (!(i % 3 == 0 or i % 5 == 0))
      ans += i;
  }
  cout << ans << endl;
  return 0;
}
