#include <stdio.h>

int main(void)
{
	long long int num;
	long long int sum;
	long long int fizz;
	long long int buzz;
	long long int fizzbuzz;

	//Junretu Sum.
	scanf("%lld", &num);
	sum = (num * (2 + (num - 1))) / 2;

	//fizz sum.
	fizz = num / 3;
	fizz = (fizz * (2 * 3 + (fizz * 3 - 3))) / 2;

	//buzz sum.
	buzz = num / 5;
	buzz = (buzz * (2 * 5 + (buzz * 5 - 5))) / 2;

	//fizz buzz sum.
	fizzbuzz = num / 15;
	fizzbuzz = (fizzbuzz * (2 * 15 + (fizzbuzz * 15 - 15))) / 2;

	sum = sum - fizz - buzz + fizzbuzz;

	printf("%lld\n", sum);
	return (0);
}
