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

int main(void) {
	long int N,S,FB,F,B;
	scanf("%ld\n",&N);
	fflush(stdout);
	S=N*(N-1)/2;
	FB=(N/15)*(N/15-1)*15/2;
	F=(N/3)*(N/3-1)*3/2;
	B=(N/5)*(N/5-1)*5/2;

	printf("%ld",S-F-B+FB);
}
