#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long int ans = 0;

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

    cout << ans << endl;

    return 0;
}