#include <stdio.h>

int main() {
	long long int N, Total = 0;
	scanf ("%lld", &N);
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		} else {
			Total += i;
		}
	}
	printf("%lld\n", Total);
	return 0;
}