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

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