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

int main() {
  int n;
  long answer = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    a[i] = i + 1;
    if(a[i] % 15 == 0) {
      answer += a[i];
    }
    else if(a[i] % 3 == 0 && !(a[i] % 15 == 0)) {
      answer += a[i];
    }
    else if(a[i] % 5 == 0 && !(a[i] % 15 == 0)) {
      answer += a[i];
    }
  }
  cout << answer << endl;
}