#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    
    uint64_t sum = 0;
    for (uint64_t i = 1; i <= N; i++) {
        if ((i % 15 != 0) &&
            (i % 5 != 0) &&
            (i % 3 != 0)) {
            sum += i;
        }
    }

    std::cout << sum;
    
    return 0;
}
