import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int C = 0;

        int nam = 0;

      
      for(int a=0;a<=K;a++){
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      }
      System.out.print(nam);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int C = 0;

        int nam = 0;

      
      for(int a=0;a<=K;a++){
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      }
      System.out.print(nam);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int C = 0;

        int nam = 0;

      
      for(int a=0;a<=K;a++){
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      }
      System.out.print(nam);
    } main {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int C = 0;

        int nam = 0;

      
      for(int a=0;a<=K;a++){
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      }
      System.out.print(nam);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int S = Integer.parseInt(sc.next()); S Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int C = 0; C 0 int nam = 0; nam 0 for(int a=0;a<=K;a++){
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      } int a=0; int a=0; a 0 a<=K a K a++ a++ a {
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      } {
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      } for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       } int b=0; int b=0; b 0 b<=K b K b++ b++ b {
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       } {
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       } C = S-a-b C S-a-b S-a-b S a b if(0<=C&&C<=K){
           nam = nam +1;
         } 0<=C&&C<=K 0<=C 0 C C<=K C K {
           nam = nam +1;
         } nam = nam +1 nam nam +1 nam 1 System.out.print(nam) System.out.print System.out System System.out nam String[] args args
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int C = 0;

        int nam = 0;

      
      for(int a=0;a<=K;a++){
       for(int b=0;b<=K;b++){
         C = S-a-b;
         if(0<=C&&C<=K){
           nam = nam +1;
         }
       }
      }
      System.out.print(nam);
    }
}