#include <stdio.h>

typedef unsigned long long int ULLI;

int main()
{
	int n;
	ULLI sum = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		if (i % 15 != 0 && i % 5 != 0 && i % 3 != 0)
			sum += i;
	}

	printf("%llu\n", sum);

	return 0;
}