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