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

int main() {
long long N;
  cin >> N;
  long long result = 0;
  for(long long a = 1;a <= N;a++){
  if(N % 3 == 0){
  }else{
    if(N % 5 == 0){
      
    }else{
     result += a; 
    }
  }
  }

cout<<result<<endl;
}