import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    }
} import java.util.*; util.* java import java.util.function.*; function.* java.util import java.math.*; math.* java public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    }
} Main public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    } main {
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int K = s.nextInt(); K s.nextInt() s.nextInt s int S = s.nextInt(); S s.nextInt() s.nextInt s int count = 0; count 0 for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		} int i = 0; int i = 0; i 0 i < K + 1 i K + 1 K 1 i++ i++ i {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		} {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		} if(i > S)
				break; i > S i S break; for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			} int j = 0; int j = 0; j 0 j < K + 1 j K + 1 K 1 j++ j++ j {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			} {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			} if(0 <= S - i - j && S - i - j <= K)
					count++; 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 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){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    }
} public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    }
} Main
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    }
}
