#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);


  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i<= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    sum += i;
  }

  cout << sum << endl;

  return 0;
}
