#include <stdio.h>

int main()
{
	long int n;
	scanf("%ld", &n);
	
	unsigned long int sum=((n*(n+1))/2) - ((((n/3)*(3+(n/3)*3))/2)+(((n/5)*(5+(n/5)*5))/2)-(((n/15)*(15+(n/15)*15))/2));
	
	printf("%lld",sum);
	
return 0;
}