#include <iostream>

int main(int argc, char *argv[]) {
  long long n, sum = 0;
  std::cin>>n;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 == 0)
      continue;
    else if (i % 5 == 0)
      continue;
    else if (i % 5 == 0 && i % 3 == 0)
      continue;
    sum += i;
  }
  std::cout << sum << std::endl;
}
