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

int main() {
    int n;
    cin >> n ;
    ll total = 0;
    rep2(i,1,n) {
        if(i % 3 == 0 && i % 5 == 0) {
        }
        else if (i % 3 == 0) {

        }
        else if(i % 5 == 0){

        }
        else total+= i;

    }
    cout << total;

    
}