#include <stdio.h>

 int main(){
 long long  N;
 long long  count;
 long long  sum= 0;
   
  scanf("%lld" , &N);
 
 for (count = 1 ; count <= N ; count++){
 	
 if((count % 3 != 0)&&(count % 5 != 0))	sum = sum + count;
 
 }
 
 printf("%lld\n" , sum);
 	
 	return 0;
 	
 }