#include <iostream>
using namespace std;

using int64 = long long;

int main() {
  int64 n;
  cin >> n;
  int64 sum = 0;
  for (int64 i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    sum += i;
  }
  cout << sum << "\n";
}
