#include    <stdio.h>

int main(void)
{
    int	n;
    unsigned long	ans = 0;

    if (fscanf(stdin, "%d", &n) != 1) {
	return 0;
    }

    for (int i = 1; i <= n; i++) {
	if (i % 3 != 0 && i % 5 != 0) {
	    ans += i;
	}
    }
    printf("%ld\n", ans);
    return 0;
}

/*
 * vim:smartindent:sw=4:sts=4:co=84:nu:wm=78:
 */
