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

int main()
{
    int n;
    cin >> n;
    vector<char> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i + 1;
    }
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 15 == 0)
            b[i] = 0;
        else if (a[i] % 3 == 0)
            b[i] = 0;
        else if (a[i] % 5 == 0)
            b[i] = 0;
        else
            b[i] = i + 1;
    }
    cout << accumulate(b.begin(), b.end(), 0) << endl;

    return 0;
}