#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
void solve(){
    
}
int main() {
  ll n,sum=0;
  cin>>n;
  for(ll i=1;i<=n;i++){
  	if(i%3!=0 and i%5!=0)
  	sum+=i;
  }
  cout<<sum;
  return 0;
}