#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long


int main() {
  int N;
  cin >> N;
  ll cnt = 0;

  for (int i = 1; i <= N; ++i) {
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    cnt += i;
  }

  cout << cnt << endl;

  return 0;
}
