import java.util.*;

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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
        for(int x = 0; x <= K; x++){
            for(int y = 0; y <= K; y++){
                int total = x + y;
                if(!(total > S) && (total + K) >= S){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}
