import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	}
} Main public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	} main {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int sum = scanner.nextInt(); sum scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 int i = 0 i 0 j = 0 j 0 k = 0; k 0 for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		} i = 0; i = 0 i 0 i<=n i n i++ i++ i {
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		} {
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		} for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			} j = 0 ; j = 0 j 0 j<=n j n j++ j++ j {
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			} {
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			} for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				} k = 0 ; k = 0 k 0 k<=n k n k++ k++ k {
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				} {
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				} if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					} i+j+k<=sum i+j+k i+j+k i j k sum {
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					} k = Math.min(n, sum-i-j) k Math.min(n, sum-i-j) Math.min Math n sum-i-j sum-i-j sum i j if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						} i+j+k<=sum i+j+k i+j+k i j k sum {
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						} j = Math.min(n, sum-i-k) j Math.min(n, sum-i-k) Math.min Math n sum-i-k sum-i-k sum i k if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							} i+j+k<=sum i+j+k i+j+k i j k sum {
								i = Math.min(n, sum-j-k);
							} i = Math.min(n, sum-j-k) i Math.min(n, sum-j-k) Math.min Math n sum-j-k sum-j-k sum j k {
						break;
					} break; if( (i+j+k)==sum ) count++; (i+j+k)==sum (i+j+k) i+j+k i j k sum 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 scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	}
} public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	}
}