
import java.io.*;
import java.util.*;
 

public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 }

} import java.io.*; io.* java import java.util.*; util.* java public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 }

} Main public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 } main {
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 } InputStream in = System.in; in System.in System System.in Scanner sc = new Scanner(in); sc new Scanner(in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int num = 0; num 0 for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       } {
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       } for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } int j= 0; int j= 0; j 0 j <= K j K j++ j++ j {
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } {
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } int z = S - i - j; z S - i - j S - i - j S i j if(z >= 0 && z <= K){
      num++;
      } z >= 0 && z <= K z >= 0 z 0 z <= K z K {
      num++;
      } num++ num System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 }

} public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 }

} Main

import java.io.*;
import java.util.*;
 

public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 }

}