#include<stdio.h>

int main() {
  int i,n;
  long long FBsum = 0,sum = 0;
  scanf("%d",&n);
  for(i = 1;i <= n;i++) {
    sum += i;
    if(i % 3 == 0 || i % 5 == 0) {
      FBsum+=i;
    }
  }

  printf("%lld\n",sum-FBsum);
}
