#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n; cin >> n;

    ll sum = 0;

    rep (i, n+1) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }

    cout << sum << endl;


    return 0;
}