#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 300123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define oo 1000000123
#define sz(x) ((int)((x).size()))
#define OUT -oo
#define left(x) (x << 1)
#define right(x) ((x << 1) | 1)
#define mid(a, b) ((a + b) >> 1)

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    ll ans = 0, x;
    cin >> x;
    for(ll i = 1; i <= x; ++i){
        if(!(i % 3 ==0) && !(i % 5 == 0)) ans += i;
    }
    cout << ans << '\n';
    return 0;
}
