import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    private final static String SPACE = " ";
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} import java.io.InputStreamReader; InputStreamReader java.io import java.io.LineNumberReader; LineNumberReader java.io public class Main {
    private final static String SPACE = " ";
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} Main private final static String SPACE = " "; SPACE " " public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } main {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } catch (Exception e) {
            System.exit(-1);
        } Exception e {
            System.exit(-1);
        } System.exit(-1) System.exit System -1 1 {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in)); stdReader new LineNumberReader(
                    new InputStreamReader(System.in)) String sStr; sStr int n = 0; n 0 int x = 0; x 0 int count = 0; count 0 while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            } (sStr = stdReader.readLine()) != null (sStr = stdReader.readLine()) sStr stdReader.readLine() stdReader.readLine stdReader null {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            } String[] inputs = sStr.split(SPACE); inputs sStr.split(SPACE) sStr.split sStr SPACE n = Integer.valueOf(inputs[0]) n Integer.valueOf(inputs[0]) Integer.valueOf Integer inputs[0] inputs 0 x = Integer.valueOf(inputs[1]) x Integer.valueOf(inputs[1]) Integer.valueOf Integer inputs[1] inputs 1 if ( n ==0 && x ==0) {
                    break;
                } n ==0 && x ==0 n ==0 n 0 x ==0 x 0 {
                    break;
                } break; for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                } {
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                } for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    } int j=i+1; int j=i+1; j i+1 i 1 j<=n j n j++ j++ j {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    } {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    } for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        } int k=j+1; int k=j+1; k j+1 j 1 k<=n k n k++ k++ k {
                            if (i+j+k == x) {
                                count++;
                            }
                        } {
                            if (i+j+k == x) {
                                count++;
                            }
                        } if (i+j+k == x) {
                                count++;
                            } i+j+k == x i+j+k i+j+k i j k x {
                                count++;
                            } count++ count System.out.println(count) System.out.println System.out System System.out count count = 0 count 0 stdReader.close() stdReader.close stdReader String[] args args public class Main {
    private final static String SPACE = " ";
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} public class Main {
    private final static String SPACE = " ";
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} Main
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    private final static String SPACE = " ";
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int x = 0;
            int count = 0;

            while ((sStr = stdReader.readLine()) != null) {
                
                // ??\???
                String[] inputs = sStr.split(SPACE);
                n = Integer.valueOf(inputs[0]);
                x = Integer.valueOf(inputs[1]);

                // ??????????????????
                if ( n ==0 && x ==0) {
                    break;
                }

                // 1 .. n?????§?????°?????????????????????3????????°???????????§????¨????x??¨?????????????????????.
                for (int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++) {
                        for(int k=j+1; k<=n; k++){
                            if (i+j+k == x) {
                                count++;
                            }
                        }
                    }
                }
                
                // ????????????
                System.out.println(count);
                // ?????????
                count = 0;
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
}