#include<stdio.h>

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