#include <bits/stdc++.h>
using namespace std;

bool judge(int ai) {
  bool div3 = (ai % 3) == 0;
  bool div5 = (ai % 5) == 0;

  if (div3 || div5) {
    return true;
  }
  return false;
}

int main()
{
  int N;
  cin >> N;

  long result = 0;
  for (int i = 1; i <= N; i++) {
    if (!judge(i)) {
      result += i;
    }
  }
  cout << result << endl;
}
