import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	} main {
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int c = 0; c 0 for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        } int i=0; int i=0; i 0 i<=a i a i++ i++ i {
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        } {
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        } for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}} int j=0; int j=0; j 0 j<=a j a j++ j++ j {if(b-i-j>=0 && b-i-j<=a){c++;}} {if(b-i-j>=0 && b-i-j<=a){c++;}} if(b-i-j>=0 && b-i-j<=a){c++;} b-i-j>=0 && b-i-j<=a b-i-j>=0 b-i-j b-i-j b i j 0 b-i-j<=a b-i-j b-i-j b i j a {c++;} c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        for(int i=0;i<=a;i++){
          for(int j=0;j<=a;j++){if(b-i-j>=0 && b-i-j<=a){c++;}}
        }
        System.out.println(c);
	}
}
