import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int K;
    int S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int K;
    int S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
} Main //フィールド
    Scanner sc; sc int K; K int S; S public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Main m = new Main(sc); m new Main(sc) m.show(m.solve()) m.show m m.solve() m.solve m sc.close() sc.close sc String[] args args //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    } Main {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    } this.sc = sc this.sc this this.sc sc K = sc.nextInt() K sc.nextInt() sc.nextInt sc S = sc.nextInt() S sc.nextInt() sc.nextInt sc Scanner sc sc //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    } solve {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    } int count = 0; count 0 for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == 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 z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        } {
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        } for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	} int y=0; int y=0; y 0 y<=K y K y++ y++ y {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	} {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	} int z = S - x - y; z S - x - y S - x - y S x y if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		} 0<=z && z<=K && x+y+z == S 0<=z && z<=K && x+y+z == S 0<=z 0 z z<=K z K x+y+z == S x+y+z x+y+z x y z S {
        			count++;
        		} count++ count return count; count //出力
    public void show(int answer) {
        System.out.println(answer);
    } show {
        System.out.println(answer);
    } System.out.println(answer) System.out.println System.out System System.out answer int answer answer public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int K;
    int S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
} public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int K;
    int S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int K;
    int S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
}
