#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    cin >> n;
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(i%3==0) continue;
        if(i%5==0) continue;
        res += i;
    }
    cout << res << endl;  

    return 0;
}