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

signed main() {
  int N;
  cin >> N;
  int a = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
    }else{
      a += i;
    }
  }
  cout << a << endl;
}