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

/**
 *
 * @author k16069kk
 */
public class Main {

    private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    }
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

    private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    }
} Main private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    } Culc {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    } int number[] = new int[num]; number new int[num] num int ans = 0; ans 0 int count = 0; count 0 for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        } int i = 0; int i = 0; i 0 i < number.length i number.length number number.length i++ i++ i {
            number[i] = i+1;
        } {
            number[i] = i+1;
        } number[i] = i+1 number[i] number i i+1 i 1 for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        } {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        } for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            } int j = i+1; int j = i+1; j i+1 i 1 j < num j num j++ j++ j {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            } {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            } for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                } int k = j+1; int k = j+1; k j+1 j 1 k < num k num k++ k++ k {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                } {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                } ans = (number[i] + number[j] + number[k]) ans (number[i] + number[j] + number[k]) number[i] + number[j] + number[k] number[i] number i number[j] number j number[k] number k if (ans == sum) count++; ans == sum ans sum count++ count return count; count int num num int sum sum /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    } main {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    } int num = 0; num 0 int sum = 0; sum 0 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line; line while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        } java.util.StringTokenizer st = new StringTokenizer(line, " "); st new StringTokenizer(line, " ") while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            } st.hasMoreTokens() st.hasMoreTokens st {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            } num = Integer.parseInt(st.nextToken()) num Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st sum = Integer.parseInt(st.nextToken()) sum Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st if (num == 0 && sum == 0) {
                break;
            } num == 0 && sum == 0 num == 0 num 0 sum == 0 sum 0 {
                break;
            } break; System.out.println(Culc(num, sum)) System.out.println System.out System System.out Culc(num, sum) Culc num sum String[] args args public class Main {

    private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    }
} public class Main {

    private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    }
} Main

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

/**
 *
 * @author k16069kk
 */
public class Main {

    private static int Culc(int num, int sum) {
        int number[] = new int[num];
        int ans = 0;
        int count = 0;
        
        for (int i = 0; i < number.length; i++) {
            number[i] = i+1;
        }
        
        for (int i = 0; i < num; i++) {
            for (int j = i+1; j < num; j++) {
                for (int k = j+1; k < num; k++) {
                    ans = (number[i] + number[j] + number[k]);
                    if (ans == sum) count++;
                }
            }
        }
        return count;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int num = 0;
        int sum = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                num = Integer.parseInt(st.nextToken());
                sum = Integer.parseInt(st.nextToken());
            }
            if (num == 0 && sum == 0) {
                break;
            }
            System.out.println(Culc(num, sum));
        }
    }
}

