#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define c(a) cout << a << "\n";
#define endl '\n'
const int MOD = 1e9 + 7;
const int N = 1e6 + 6;
vector<ll> g[N];
int main()
{

    ll n;
    cin >> n;
    ll sum = n * (n + 1) / 2;
    ll p = n / 3;
    sum -= 3 * ((p * (p + 1)) / 2);
    p = n / 5;
    sum -= 5 * ((p * (p + 1)) / 2);
    p = n / 15;
    sum += 15 * ((p * (p + 1)) / 2);
    //sum += 15 * (n / 15);
    c(sum)

        return 0;
}