#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a,b,c=0;
  scanf("%d %d",&a, &b);
  for (int i = a; i >= 0; i--) {
    for (int j = a; j >= 0; j--) {
        if (i+j <= b && i+j+a >=b) {
          c++;
      }
    }
  }
  printf("%d\n",c);
  return 0;
}
