#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double

ll sum(ll n) {
    return n*(n+1)/2;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll n;
    cin >> n;    
    ll res = sum(n) - sum(n/3)*3 - sum(n/5)*5+sum(n/15)*15;
    cout << res << endl;
}
