import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    } main {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    } int x x y y z z k k s s count=0; count 0 Scanner scan = new Scanner(System.in); scan new Scanner(System.in) k = scan.nextInt() k scan.nextInt() scan.nextInt scan s = scan.nextInt() s scan.nextInt() scan.nextInt scan if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        } s / k == 3 s / k s k 3 {
            count++;
        } count++ count {
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        } for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             } x = 0; x = 0 x 0 x <= k x k x++ x++ x {
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             } {
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             } for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                } y = 0; y = 0 y 0 y<=k y k y++ y++ y {
                    if(s - x-y >=0 && s -x-y <=k) count++;
                } {
                    if(s - x-y >=0 && s -x-y <=k) count++;
                } if(s - x-y >=0 && s -x-y <=k) count++; s - x-y >=0 && s -x-y <=k s - x-y >=0 s - x-y s - x-y s x y 0 s -x-y <=k s -x-y s -x-y s x y k count++ count 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) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    }
}