#include <stdio.h>

#define ll long long

int main()
{
	ll n, sum,i;
	scanf("%lld",&n);
	
	ll n3,n5,n15;
	n3 = n/3; 
	n5 = n/5;
	n15 = n/15;
	
	sum = (n*(n+1)-n3*(3*n3+3)-n5*(5*n5+5)+n15*(15*n15+15))/2;
	printf("%lld\n",sum);
	
	return 0;
}
