#include<stdio.h>
int main(void){
  int p[1000000000]={0},N,i,ans=0;
  scanf("%d",&N);
  for(i=1;i<=N;i=i+1){
    if(i%3==0||i%5==0){
      p[i]=0;
    }else{p[i]=i;}
  }
  for(i=1;i<=N;i=i+1){
    ans+=p[i];
  }
  printf("%d\n",ans);
}
