#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N; cin>>N;
    ll sum=0;
    for(int i=1;i<N;i++){
        if(i%3==0||i%5==0)continue;
        sum+=i;
    }
    cout<<sum<<endl;
}
