#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>  
#include <cstdlib>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

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

    cout << ans << endl;
    return 0;
}