#include <stdio.h>

int main(void)
{
  int n,i;
  int goukei = 0;
  
  scanf("%d",&n);
  
  for(i=1; i<=n; i++){
    if(i%3!=0&&i%5!=0)
      goukei = goukei + i;
  }
  printf("%d",goukei);
  return 0;
}