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