#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll N;
    cin >> N;

    ll sum = 0;

    for(ll i=0; i<N; i++){
        if(i % 3==0 || i%5 ==0){
            continue;
        }
        else{
            sum += i;
        }
    }

    cout << sum << endl;
}