#include <stdio.h>
int main() {
    long long n;
    scanf("%lld", &n);
    long long t1 = n / 3, t2 = n / 5, t3 = n / 15;
    printf("%lld\n", n * (n + 1) / 2 - 3 * t1 * (t1 + 1) / 2 - 5 * t2 * (t2 + 1) / 2 + 15 * t3 * (t3 + 1) / 2);
}
