#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll N;

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