


import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		long toori=0;

		if(K<=200) {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		}
		else {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		}

	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		long toori=0;

		if(K<=200) {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		}
		else {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		}

	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		long toori=0;

		if(K<=200) {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		}
		else {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		}

	} main {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		long toori=0;

		if(K<=200) {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		}
		else {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		}

	} 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 long toori=0; toori 0 if(K<=200) {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		}
		else {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		} K<=200 K 200 {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		} for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			} int i=0; int i=0; i 0 i<=K i K i++ i++ i {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			} {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			} for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				} int j=0; int j=0; j 0 j<=K j K j++ j++ j {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				} {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				} for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					} int k=0; int k=0; k 0 k<=K k K k++ k++ k {
						if(i+j+k==S) {
							toori++;
						}
					} {
						if(i+j+k==S) {
							toori++;
						}
					} if(i+j+k==S) {
							toori++;
						} i+j+k==S i+j+k i+j+k i j k S {
							toori++;
						} toori++ toori System.out.println(toori) System.out.println System.out System System.out toori {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		} if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			} S<=K S K {
				System.out.println((S+2)*(S+1)/2);
			} System.out.println((S+2)*(S+1)/2) System.out.println System.out System System.out (S+2)*(S+1)/2 (S+2)*(S+1) (S+2) S 2 (S+1) S 1 2 if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			} S>K && S<=2*K S>K S K S<=2*K S 2*K 2 K {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			} System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2) System.out.println System.out System System.out (S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2 (S+2)*(S+1)/2 (S+2)*(S+1) (S+2) S 2 (S+1) S 1 2 3*(S-K+1)*(S-K)/2 3*(S-K+1)*(S-K) 3*(S-K+1)*(S-K) 3 (S-K+1) S-K S K 1 (S-K) S K 2 if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			} S>2*K S 2*K 2 K {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			} int tmp=3*K-S; tmp 3*K-S 3*K 3 K S System.out.println((tmp+2)*(tmp+1)/2) System.out.println System.out System System.out (tmp+2)*(tmp+1)/2 (tmp+2)*(tmp+1) (tmp+2) tmp 2 (tmp+1) tmp 1 2 String[] args args



import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		long toori=0;

		if(K<=200) {
			for(int i=0; i<=K; i++) {
				for(int j=0; j<=K; j++) {
					for(int k=0; k<=K; k++) {
						if(i+j+k==S) {
							toori++;
						}
					}
				}
			}
			System.out.println(toori);
		}
		else {
			if(S<=K) {
				System.out.println((S+2)*(S+1)/2);
			}
			else if(S>K && S<=2*K) {
				System.out.println((S+2)*(S+1)/2-3*(S-K+1)*(S-K)/2);

			}
			else if(S>2*K) {
				int tmp=3*K-S;
				System.out.println((tmp+2)*(tmp+1)/2);
			}
		}

	}
}