import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        }
        
        System.out.println(ans);
    }
}	 import java.util.Scanner; Scanner java.util public class Main {
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        }
        
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        }
        
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= 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 for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        } int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        } {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        } for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	} int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	} {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	} if (x+y > S)
        			break; x+y > S x+y x y S break; if (S - (x + y) <= K) {
        			ans++;
        		} S - (x + y) <= K S - (x + y) S (x + y) x y K {
        			ans++;
        		} ans++ ans 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) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        }
        
        System.out.println(ans);
    }
} public class Main {
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        }
        
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        for (int x = 0; x <= K; x++) {
        	for (int y = 0; y <= K; y++) {
        		if (x+y > S)
        			break;
        		
        		if (S - (x + y) <= K) {
        			ans++;
        		}
        	}
        }
        
        System.out.println(ans);
    }
}	