import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    } main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc int i i j; j int count = 0; count 0 for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        } i = 0; i = 0 i 0 i <= k i k i++ i++ i {
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        } {
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        } for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	} j = 0; j = 0 j 0 j <= k j k j++ j++ j {
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	} {
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	} if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                } s - (i + j) >= 0 && s - (i + j) <= k s - (i + j) >= 0 s - (i + j) s (i + j) i j 0 s - (i + j) <= k s - (i + j) s (i + j) i j k {
                  count += 1;
                } count += 1 count 1 System.out.print(count) System.out.print System.out System System.out count String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    }
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int k = sc.nextInt();
      	int s = sc.nextInt();
        int i,j;
        int count = 0;

        for(i = 0;i <= k;i++){
	        for(j = 0;j <= k;j++){
		        if(s - (i + j) >= 0 && s - (i + j) <= k){
                  count += 1;
                }
        	}          
        }
      	System.out.print(count);
      
    }
}