#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

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

    Int sum = 0;
    rep1(i,N){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
}