#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ll n; cin >> n;
    ll n1 = n/3;
    ll n2 = n/5;
    ll n3 = n/15;
    ll ans;
    ans = (n+1)*n/2-3*(1+n1)*n1/2-5*(1+n2)*n2/2+15*(1+n3)*n3/2;
    cout << ans << endl;
}