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

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  } main {
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan int s = scan.nextInt(); s scan.nextInt() scan.nextInt scan int cnt = 0; cnt 0 for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    } int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    } {
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    } for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      } int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      } {
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      } int z = s - (x+y); z s - (x+y) s (x+y) x y if(0 <= z && z <= k)
          cnt++; 0 <= z && z <= k 0 <= z 0 z z <= k z k cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  }
} Main
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  }
}
