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

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