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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    }

    public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    }

    public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) StringBuilder builder = new StringBuilder(); builder new StringBuilder() String[] columns; columns int a1 = 0; a1 0 int a2 = 0; a2 0 int res = 0; res 0 while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        } true {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        } String line = reader.readLine(); line reader.readLine() reader.readLine reader columns = line.split(" ") columns line.split(" ") line.split line " " a1 = Integer.parseInt(columns[0]) a1 Integer.parseInt(columns[0]) Integer.parseInt Integer columns[0] columns 0 a2 = Integer.parseInt(columns[1]) a2 Integer.parseInt(columns[1]) Integer.parseInt Integer columns[1] columns 1 if (a1 == 0 && a2 == 0) {
                break;
            } a1 == 0 && a2 == 0 a1 == 0 a1 0 a2 == 0 a2 0 {
                break;
            } break; res = pattern(a1, a2) res pattern(a1, a2) pattern a1 a2 builder.append(res)
                   .append("\n") builder.append(res)
                   .append builder.append(res) builder.append builder res "\n" System.out.print(builder) System.out.print System.out System System.out builder String[] args args public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    } pattern {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    } int list = 0; list 0 for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        } int x = 1; int x = 1; x 1 x <= a1 x a1 x++ x++ x {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        } {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        } for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            } int y = x + 1; int y = x + 1; y x + 1 x 1 y <= a1 y a1 y++ y++ y {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            } {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            } for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                } int z = y + 1; int z = y + 1; z y + 1 y 1 z <= a1 z a1 z++ z++ z {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                } {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                } if (x + y + z == a2) {
                        list += 1;
                    } x + y + z == a2 x + y + z x + y + z x y z a2 {
                        list += 1;
                    } list += 1 list 1 return list; list int a1 a1 int a2 a2 public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    }

    public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    }

    public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    }
} Main

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    }

    public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    }
}