#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    int n;
    scanf("%d", &n);

    long mysum = 0;

    int cnt = 1;

    while (cnt <= n) {
        if (!(cnt % 3 == 0 || cnt % 5 == 0)) {
            mysum += cnt;
        }
        cnt++;
    }

    printf("%ld", mysum);

    return 0;

}