#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
const int N = 200001;
using namespace std;




int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i < n + 1; i++) {
        if (i % 3 && i % 5) {
            ans += i;
        }
    }

    cout << ans;


}