#include <stdio.h>
int main(){
	long long int n,threes,fives,fifteens,sum=0;
	scanf("%lld",&n);
	threes=(long long int)(n/3);
	threes=3*(threes)*(threes+1)/2;
	fives=(long long int)(n/5);
	fives=5*(fives)*(fives+1)/2;
	fifteens=(long long int)(n/15);
	fifteens=15*fifteens*(fifteens+1)/2;
	sum=(n*(n+1)/2)+fifteens-fives-threes;
	printf("%lld\n",sum);
	return 0;
}
