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

int main() {
  int N;
  cin >> N;
  
  int64_t result=0;
  for (int i; i < N; i++) {
    if (!(i+1 %3 == 0) && !(i+1 %5 == 0)) {
      result = result + i+1;
    }
  }
  cout << result << endl;
}