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

int main() {
  int n;
  cin >> n;
  vector<int> line(n);
  
  for (int i = 0; i < n; i++) {
    if ((i % 15) == 0) {
      line.at(i) = 0;
    } else if ((i % 3) == 0) {
      line.at(i) = 0;
    } else if ((i % 5) == 0) {
      line.at(i) = 0;
    } else {
      line.at(i) = i;
    };
  };
  long sum = 0;
  for (int i = 0; i < n; i++) {
    sum = sum + line.at(i);
  }
  cout << sum;
}
