#include <bits/stdc++.h>
using namespace std;

int main() {
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
  int64_t N,a;
  cin>>N;
  a=0;
  rep(i,N){
    if(i%3!=0&&i%5!=0)
      a+=i;
  }
  cout<<a;
}