/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define debug(x) cerr << #x << " "<< x << endl

int main()
{
    ll n, sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 and i % 5 != 0) sum += i;
    }
    cout << sum << endl;

    return 0;
}