#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second
#define endl "\n"
#define pie 3.1415926535

int main(){
  int n;
  cin >> n;
  long long sum=0;
  for(int i=1;i<n;i++){
      if(i%3!=0 && i%5!=0)
          sum += i;
  }
  
  cout << sum <<endl;
  return 0;
  
}




