import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        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 X = 0 X 0 Y = 0 Y 0 Z = 0; Z 0 int count = 0; count 0 for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        } {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        } for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            } int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            } {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            } X = i X i Y = j Y j Z = S - X - Y Z S - X - Y S - X - Y S X Y int total = X + Y + Z; total X + Y + Z X + Y + Z X Y Z if(total == S && Z >= 0 && Z <= K){
                        count++;
                    } total == S && Z >= 0 && Z <= K total == S && Z >= 0 && Z <= K total == S total S Z >= 0 Z 0 Z <= K Z K {
                        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) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        }
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int X = 0, Y = 0, Z = 0;
        int count = 0;
        for(int i = 0; i <= K; i++) {
            for(int j = 0; j <= K; j++) {
                    X = i;
                    Y = j;
                    Z = S - X - Y;
                    int total = X + Y + Z;
                    if(total == S && Z >= 0 && Z <= K){
                        count++;
                    }
            }
        }
        System.out.println(count);
    }
}
