import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  }
} Main public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  } main {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k=sc.nextInt() k sc.nextInt() sc.nextInt sc s=sc.nextInt(); s sc.nextInt() sc.nextInt sc int count=0; count 0 for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++; int x=0; int x=0; x 0 x<=k x k x++ x++ x for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++; for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++; int y=0; int y=0; y 0 y<=k y k y++ y++ y if(s-x-y<=k&&0<=s-x-y)count++; if(s-x-y<=k&&0<=s-x-y)count++; s-x-y<=k&&0<=s-x-y s-x-y<=k s-x-y s-x-y s x y k 0<=s-x-y 0 s-x-y s-x-y s x y count++ count System.out.print(count) System.out.print System.out System System.out count sc.close() sc.close sc String[] args args public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  }
} public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k=sc.nextInt(),s=sc.nextInt();
	int count=0;
	for(int x=0;x<=k;x++)
		for(int y=0;y<=k;y++)
			if(s-x-y<=k&&0<=s-x-y)count++;
			
	System.out.print(count);
	sc.close();
  }
}
