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

int main(void)
{
  long long int n,n3,n5,n15,sum,sum3,sum5,sum15;

  scanf("%lld",&n);

  sum=(n*(n+1))/2;
  n3=n/3;
  n5=n/5;
  n15=n/15;
  sum3=((3+3+3*(n3-1))*n3)/2;
  sum5=((5+5+5*(n5-1))*n5)/2;
  sum15=((15+15+15*(n15-1))*n15)/2;

  sum=sum-sum3-sum5+sum15;
  printf("%lld",sum);

	return 0;
}
