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