#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long N;
    cin >> N;
    long ans = 0;
    ans = (1 + N) * N / 2;
    ans -= 3 * (1 + N / 3) * (N / 3) /2 + 5 * (1 + N / 5) * (N / 5) /2 - 15 * (1 + N / 15) * (N / 15) / 2;
    cout << ans << endl;
    return 0;
}