#include<bits/stdc++.h>

using namespace std;

int main(){
  typedef long long int ll;
  ll N,sum = 0;
  cin >> N;
  for(ll i = 0; i < N; i++){
    if(i%5 != 0 && i%3 != 0){sum += i;}
  }
  

  cout << sum << endl;

  return 0;
}