#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define PB push_back
const ll MOD = 1e9 + 7;
const int MAX = 10000000;

int main(){
    ll N;
    cin >> N;
    ll sum = N*(N+1)/2;
    if(N >= 3){
        sum -= N*(1+(ll)(N/3))/2;
    }
    if(N >= 5){
        sum -= N*(1+(ll)(N/5))/2;
    }
    if(N >= 15){
        sum += N*(1+(ll)(N/15))/2;
    }
    cout << sum << endl;
}