import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    }
} Main public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    } main {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    } BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) StringTokenizer tokenizer = new StringTokenizer(input.readLine()); tokenizer new StringTokenizer(input.readLine()) int k = Integer.parseInt(tokenizer.nextToken()); k Integer.parseInt(tokenizer.nextToken()) Integer.parseInt Integer tokenizer.nextToken() tokenizer.nextToken tokenizer int s = Integer.parseInt(tokenizer.nextToken()); s Integer.parseInt(tokenizer.nextToken()) Integer.parseInt Integer tokenizer.nextToken() tokenizer.nextToken tokenizer int count = 0; count 0 for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        } int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        } {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        } for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            } int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            } {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            } if (s >= i+j && s-(i+j) <= k){
                    count++;
                } s >= i+j && s-(i+j) <= k s >= i+j s i+j i j s-(i+j) <= k s-(i+j) s (i+j) i j k {
                    count++;
                } count++ count if (s < i+j)
                    break; s < i+j s i+j i j break; if (s < i)
                break; s < i s i break; 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)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    }
} public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int k = Integer.parseInt(tokenizer.nextToken());
        int s = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                if (s >= i+j && s-(i+j) <= k){
                    count++;
                }
                if (s < i+j)
                    break;
            }
            if (s < i)
                break;
        }
        System.out.println(count);

    }
}
