include <stdio.h>
#include <stdint.h>

uint64_t sum_by(int base, int last) {
        uint64_t _last;

        if (base == 0) {
                perror("sum_by");
                return 1;
        }

        _last = last / base;

        return (_last * (_last + 1) / 2) * base;
}

uint64_t solve(int n) {
        return sum_by(1, n) - sum_by(3, n) - sum_by(5, n) + sum_by(15, n);
}

int main() {
        int n;
        int rc;

        rc = scanf("%7d", &n);
        if (rc == 0) {
                perror("scanf");
                return 1;
        }

        printf("%lld\n", solve(n));

        return 0;
}
