import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[] A=new int[101];
int a=0;
while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
}
for(int z=0;z<a;z++)
System.out.println(A[z]);
}
} import java.util.Scanner; Scanner java.util class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[] A=new int[101];
int a=0;
while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
}
for(int z=0;z<a;z++)
System.out.println(A[z]);
}
} Main public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[] A=new int[101];
int a=0;
while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
}
for(int z=0;z<a;z++)
System.out.println(A[z]);
} main {
Scanner scan=new Scanner(System.in);
int[] A=new int[101];
int a=0;
while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
}
for(int z=0;z<a;z++)
System.out.println(A[z]);
} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int[] A=new int[101]; A new int[101] 101 int a=0; a 0 while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
} true {
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
} String x=scan.next(); x scan.next() scan.next scan String y=scan.next(); y scan.next() scan.next scan int n=Integer.parseInt(x); n Integer.parseInt(x) Integer.parseInt Integer x int m=Integer.parseInt(y); m Integer.parseInt(y) Integer.parseInt Integer y if(n==0&&m==0)
break; n==0&&m==0 n==0 n 0 m==0 m 0 break; int sum=0; sum 0 for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
} {
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
} for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
} int j=i+1; int j=i+1; j i+1 i 1 j<=n j n j++ j++ j {
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
} {
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
} for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
} int k=j+1; int k=j+1; k j+1 j 1 k<=n k n k++ k++ k {
if(i+j+k==m)
sum++;
} {
if(i+j+k==m)
sum++;
} if(i+j+k==m)
sum++; i+j+k==m i+j+k i+j+k i j k m sum++ sum A[a]=sum A[a] A a sum a++ a for(int z=0;z<a;z++)
System.out.println(A[z]); int z=0; int z=0; z 0 z<a z a z++ z++ z System.out.println(A[z]); System.out.println(A[z]) System.out.println System.out System System.out A[z] A z String[] args args
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[] A=new int[101];
int a=0;
while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
}
for(int z=0;z<a;z++)
System.out.println(A[z]);
}
}