#include <iostream>

using namespace std;

int main() {
    long long int N;
    long long int res = 0;

    cin >> N;

    for (long long int i = 1; i <= N; ++i) {
        if (i % 15 == 0 || i % 5 == 0 || i % 3 == 0) {
            res += i;
        }
    }

    cout << res;
    return 0;
}