#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 1; i < n+1; i++)

int main () {
  int n;
  cin >> n;
  long long sum = 0;
  rep(i, n) if (i % 3 != 0 && i % 5 != 0) sum += i;
  cout << sum << endl;
}