#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




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