#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

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

    cout << ans << endl;

}