#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
  #endif

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n;
    cin >> n;
    ll sum = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 == 0 && i % 5 == 0)
            continue;
        else if (i % 3 == 0)
            continue;
        else if (i % 5 == 0)
            continue;
        else
            sum += i;
    }
    cout << sum << endl;
    return 0;
}