import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
  int[] m;
  while((m=map!(to!int)(readln.strip.split).array)!=[0,0]) {
    int n=m[0],x=m[1],sum = 0;

    foreach(i;1..n)
      foreach(j;i+1..x-i)
      {
          int k = x-i-j;
          if(j<k && k<=n) sum ++;
      }
    writeln(sum);
  }
}