#include<bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    long long sum = ((1 + N) * N / 2) - 3 * ((1 + (N/3)) * N/3 / 2) - 5 * ((1 + (N/5)) * N/5 / 2) + 15 * ((1 + (N/15)) * N/15 / 2);

    cout << sum << endl;
    
}