#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  ll ans = 0;
  int N;
  cin >> N;
  rep(i, N){
    if(i % 3 != 0 || i % 5 != 0)
      ans += i;
  }
  cout << ans << endl;
}