import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(count);

  }
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(count);

  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(count);

  } main {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(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 count = 0; count 0 int stack; stack int start = 0; start 0 if(s - 2*k > 0) start = s - 2*k; s - 2*k > 0 s - 2*k s 2*k 2 k 0 start = s - 2*k start s - 2*k s 2*k 2 k int end = k; end k if(s < k) end = s; s < k s k end = s end s for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } {
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } stack = s - x stack s - x s x if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        } stack <= 2*k && stack >= 0 stack <= 2*k stack 2*k 2 k stack >= 0 stack 0 {
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        } if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1; stack <= k stack k count += stack + 1 count stack + 1 stack 1 count += k - (stack - k) + 1 count k - (stack - k) + 1 k - (stack - k) k (stack - k) stack k 1 System.out.println(count) System.out.println 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 count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(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 count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(count);

  }
} Main
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;
    int stack;
    
    int start = 0;
    if(s - 2*k > 0) start = s - 2*k;
    
    int end = k;
    if(s < k) end = s;
        
    for(int x = 0; x <= k; x++){
    	stack = s - x;
      	if(stack <= 2*k && stack >= 0){
      		if(stack <= k) count += stack + 1;
      		else count += k - (stack - k) + 1;
        }
    } 
   	
  	System.out.println(count);

  }
}
