#include <stdio.h>

int main (){
  long int i,N,sum = 0;
  scanf("%d",&N);
  for(i = 1; N >= i; i++){
	if((i%3 == 0) || (i%5 == 0)){
	  continue;
    }
	sum = sum + i;
  }
  printf("%d",sum);
  return 0;
}
