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

int main(){
  int64_t N;
  cin >> N;
  int64_t x=0;
  for(int i=0;i<N;i++){
    if((i+1)%3!=0&&(i+1)%5!=0){
      x+=i+1;
    }
  }
  cout << x << endl;
}