#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

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