import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    }
} import java.util.*; util.* java import java.util.Collections; Collections java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    } main {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int S = Integer.parseInt(sc.next()); S Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long count = 0; count 0 for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        } int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        } {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        } if(x == S) {
                count++;
                break;
            } x == S x S {
                count++;
                break;
            } count++ count break; if(x > S) {
                break;
            } x > S x S {
                break;
            } break; if(x+K+K < S) {
                continue;
            } x+K+K < S x+K+K x+K+K x K K S {
                continue;
            } continue; for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            } {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            } if(x + y == S) {
                    count++;
                    break;
                } x + y == S x + y x y S {
                    count++;
                    break;
                } count++ count break; if(x + y > S) {
                    break;
                } x + y > S x + y x y S {
                    break;
                } break; if(x+y+K < S) {
                    continue;
                } x+y+K < S x+y+K x+y+K x y K S {
                    continue;
                } continue; 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 sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    }
} Main
import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        long count = 0;
        
        for(int x = 0; x <= K; x++) {
            if(x == S) {
                count++;
                break;
            }
            if(x > S) {
                break;
            }
            if(x+K+K < S) {
                continue;
            }
            for(int y = 0; y <= K; y++) {
                if(x + y == S) {
                    count++;
                    break;
                }
                if(x + y > S) {
                    break;
                }
                if(x+y+K < S) {
                    continue;
                }
                count++;
            }
            
        }
        
        System.out.println(count);
        
    }
}