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

using namespace std;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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