#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void){
	
	long long int n,three,five,fift,sum = 0,sum3,sum5,sum15;
	scanf("%ld", &n);
	if(n%3 == 0 ) three = n;
	else three = n-(n%3);
	if(n%5 == 0 ) five = n;
	else five = n-(n%5);
	if(n%15 == 0 ) fift = n;
	else fift = n-(n%15);
	sum3 = ((three/3)*(6+((three/3)-1)*3))/2;
	sum5 = ((five/5)*(10+((five/5)-1)*5))/2;
	sum15 = ((fift/15)*(30+((fift/15)-1)*15))/2;
	sum = n*(1+n)/2-sum3-sum5+sum15;
	
	printf("%ld", sum);
	
}