#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;

int main() {
  ll N;
  ll sum = 0;
  std::cin >> N;
  for (ll i = 1; i < N+1; i++) {
    if (N%3 == 0 || N%5 == 0) {
      continue;
    }
    sum += i;
  }
  std::cout << sum << '\n';
}
