#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    ll n;
    cin >> n;
    n++;
    ll ans= 0;
    rep(i,n) {
        if(i%3==0||i%5==0) ;
        else    ans+=i;
    }

    cout<< ans << endl;

 return 0;
}