#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

int main() {
    int64_t n; cin >> n;
    int64_t sum1 = n*(n+1)/2;
    int64_t sum3 = 3*(n/3)*(n/3+1)/2;
    int64_t sum5 = 5*(n/5)*(n/5+1)/2;
    int64_t sum15 = 15*(n/15)*(n/15+1)/2;
    int64_t ans = sum1-sum3-sum5+sum15;

    cout << ans << endl;
}
