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