#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        if ((i+1)%3!=0 && (i+1)%5!=0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
}