#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long

int main()
{
    ll n;
    cin >> n;
    ll n3 = n / 3;
    ll n5 = n/5;
    ll n15 = n / 15;
    ll nsum = n * (n + 1) / 2;
    ll n3sum = 3 * n3 * (n3 + 1) / 2;
    ll n5sum = 5 * n5 * (n5 + 1) / 2;
    ll n15sum = 15 * n15 * (n15 + 1) / 2;
    cout << nsum - n3sum - n5sum + n15sum << endl;
}