import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
    
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} Main public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    } main {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] s = br.readLine().split(" ",0); s br.readLine().split(" ",0) br.readLine().split br.readLine() br.readLine br " " 0 int K = Integer.parseInt(s[0]); K Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int S = Integer.parseInt(s[1]); S Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int X X Y Y Z; Z int count = 0; count 0 for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	} X = 0; X = 0 X 0 X <= K X K X++ X++ X {
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	} {
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	} for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    } Y = 0; Y = 0 Y 0 Y <= K Y K Y++ Y++ Y {
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    } {
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    } Z = S - X - Y Z S - X - Y S - X - Y S X Y if(0 <= Z && Z  <= K){
		    count++;
		} 0 <= Z && Z  <= K 0 <= Z 0 Z 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) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} public class Main{
    
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int K = Integer.parseInt(s[0]);
	int S = Integer.parseInt(s[1]);
	int X,Y,Z;
	int count = 0;
	for(X = 0; X <= K; X++){
	    for(Y = 0; Y <= K; Y++){
		Z = S - X - Y;
		if(0 <= Z && Z  <= K){
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
}
