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