import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    } main {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int K = Integer.parseInt(scan.next()); K Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int S = Integer.parseInt(scan.next()); S Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int cou = 0; cou 0 for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        } int i = 0; int i = 0; i 0 i<=K i K i++ i++ i {
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        } {
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        } for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            } int j = 0; int j = 0; j 0 j<=K j K j++ j++ j {
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            } {
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            } if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                } 0<=S-i-j&&S-i-j<=K 0<=S-i-j 0 S-i-j S-i-j S i j S-i-j<=K S-i-j S-i-j S i j K {
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                } if(i+j+(S-i-j) == S){
                        cou++;
                    } i+j+(S-i-j) == S i+j+(S-i-j) i+j+(S-i-j) i j (S-i-j) S-i-j S i j S {
                        cou++;
                    } cou++ cou System.out.println(cou) System.out.println System.out System System.out cou String[] args args public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = Integer.parseInt(scan.next());
        int S = Integer.parseInt(scan.next());
        int cou = 0;

        for(int i = 0;i<=K;i++){
            for(int j = 0;j<=K;j++){
                if(0<=S-i-j&&S-i-j<=K){
                    if(i+j+(S-i-j) == S){
                        cou++;
                    }
                }
            }
        }
        System.out.println(cou);
    }
}