#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
typedef long long ll;
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    rep(i, N){
        if (i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans;
    return 0;
}
