#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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