#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll out = 0;
    ll sum = (N+1)*N/2;
    ll fizz = ((N/3)*3+3)*(N/3)/2;
    ll buzz = ((N/5)*5+5)*(N/5)/2;
    ll fizzbuzz = ((N/15)*15+15)*(N/15)/2;
    out = sum - fizz - buzz + fizzbuzz;
    cout << out << endl;
    return 0;
}
