import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    }
} import java.util.*; util.* java import java.util.Arrays; Arrays java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    } main {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int S = scanner.nextInt(); S scanner.nextInt() scanner.nextInt scanner int sub = 0; sub 0 int count = 0; count 0 for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        } {
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        } if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            } i != S i S {
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            } for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                } {
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                } if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    } i+j != S i+j i j S {
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    } sub = S - (i+j) sub S - (i+j) S (i+j) i j if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        } sub>=0 && sub<=K sub>=0 sub 0 sub<=K sub K {
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        } count++ count if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    } i+j == S i+j i j S {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    } count++ count break; if(i == S){
               // System.out.println("i:"+i);
                count++;
            } i == S i S {
               // System.out.println("i:"+i);
                count++;
            } 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 {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    }
} Main
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        int sub = 0;
        
        int count = 0;
        for(int i=0;i<=K;i++){
            if(i != S){
                for(int j=0;j<=K;j++){
                    if(i+j != S){
                        sub = S - (i+j);
                        if(sub>=0 && sub<=K){
                        //System.out.println("i:"+i+" j:"+j+"k:"+sub);
                        count++;
                        
                        }
                    }else if(i+j == S)
                    {
                        //System.out.println("i:"+i+" j:"+j);
                        count++;
                        break;
                    }
                }
                
            }else if(i == S){
               // System.out.println("i:"+i);
                count++;
            }
        }
        
        System.out.println(count);
    }
}