#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define D(i, a, b) for (int i = (a); i >= (b); i--)
#define R(i, a, b) for (int i = (a); i < (b); i++)
#define N 500000
#define ALL(vt) vt.begin(), vt.end()
#define ALLR(vt) vt.rbegin(), vt.rend()
int main(){
    int n; cin >> n;
    ll ans = 0;
    R(i, 1, n+1){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans;
}