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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in)); br new BufferedReader(
			new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int k = Integer.parseInt(input[0]); k Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int s = Integer.parseInt(input[1]); s Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 int x=0; x 0 int y=0; y 0 int z=0; z 0 int count = 0; count 0 for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		} int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		} {
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		} x = i x i for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			} int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			} {
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			} y = j y j int rest = s-x-y; rest s-x-y s-x-y s x y if(rest >= 0 && rest <= k){
					count++;
				} rest >= 0 && rest <= k rest >= 0 rest 0 rest <= k rest 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[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= 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[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int k = Integer.parseInt(input[0]);
		int s = Integer.parseInt(input[1]);
		int x=0;
		int y=0; 
		int z=0;
		int count = 0;

		for(int i = 0; i <= k;i++){
			x = i;
			for(int j = 0; j <= k; j++){
				y = j;
				int rest = s-x-y;
				if(rest >= 0 && rest <= k){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}