#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,ans=0; cin>>n;
  for(ll i=1;i<=n;i++){
    if(i%3!==0 && i%5!==0){
      ans+=i;
    }
  }
  cout<<ans;
}