#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

int main() {
    long long N;
    cin >> N;

    long long sum = 0;
    for (long long i = 1; i <= N; ++i) {
        if ((i % 3 != 0) && (i % 5 != 0)) {
            sum += i;
        }
    }
    cout << sum << endl;
    //cout << setprecision(15) << endl;
    return 0;
}
