#include<stdio.h>

int main(void){
  long int N; scanf("%ld",&N);

  long long int ans = 0;

  for(long int i = 1;i <= N;i++){
    if((i%3 != 0)&&(i%5) != 0){
      ans += i;
    }
  }

  printf("%lld",ans);
  return 0;
}