#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;



int main(){
    ll n;cin>>n;
    ll an=0;
    rep(i,1,n+1){
        if(i%3==0||i%5==0)continue;
        an+=i;
    }
    cout<<an<<endl;
}
    







