import 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 ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int k = sc.nextInt();
		int s = sc.nextInt();
        int ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int k = sc.nextInt();
		int s = sc.nextInt();
        int ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int k = sc.nextInt();
		int s = sc.nextInt();
        int ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	} 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 ans = 0; ans 0 System.out.println(ans) System.out.println System.out System System.out ans 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 ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int k = sc.nextInt();
		int s = sc.nextInt();
        int ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
} Main
import 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 ans = 0;
       
        aLoop: for(int a = 0; a <= k; a++) {
          bLoop: for(int b = 0; b <= k; b++) {
            int abSum = a + b;
            if (abSum > s) {
              continue aLoop;
            } else if (s - abSum <= k) {
              ans++;
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}