#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 100005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;



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

    return 0;
}
