#include<stdio.h>

int main(int argc, char *argv[])
{
  int n;
  int cnt;
  long long sum = 0;
  
  scanf("%d", &n);
  for(cnt = 1; cnt <= n; cnt++){
    if(((cnt % 3) == 0) || ((cnt % 5) == 0)){
        ;
    }else{
        sum += cnt;
  		//printf("%d ", cnt);
    }
  }

  //sum = (long long)0x1000000000;
  
  printf("%lld\n", sum);
  return 0;
}