import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	} main {
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long K = sc.nextInt(); K sc.nextInt() sc.nextInt sc long S = sc.nextInt(); S sc.nextInt() sc.nextInt sc long res = 0; res 0 for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		} long i = Math.min(K, S); long i = Math.min(K, S); i Math.min(K, S) Math.min Math K S i>=0 i 0 i-- i-- i {
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		} {
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		} long v = S-i; v S-i S i if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			} v < K v K res+=(v+1) res (v+1) v 1 if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			} v == K v K res+=(K+1) res (K+1) K 1 if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			} v <= 2*K v 2*K 2 K {
				long a = v-K;
				res+=K-a+1;
			} long a = v-K; a v-K v K res+=K-a+1 res K-a+1 K-a K a 1 System.out.println(res) System.out.println System.out System System.out res String args[] args public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	}
} public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}
		}
		System.out.println(res);
	}
}