#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int64_t N;
  cin >> N;
  int64_t res = 0;
  for (int64_t i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      res += i;
    }
  }
  cout << res << endl;

  return 0;
}
