#include<bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll sol = 0;
    for(int i = 0; i < n; i++){
        if((i + 1) % 3 != 0 && (i + 1) % 5 != 0)
            sol += i + 1;
    }
    cout << sol;
}