#include <stdio.h>

int main() {
	int n = 0;
	unsigned long long total = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			total += i;
		}
	}
	printf("%llu",total);

	return 0;
}