import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    } main {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        } s.hasNextInt() s.hasNextInt s {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        } int n = s.nextInt(); n s.nextInt() s.nextInt s int x = s.nextInt(); x s.nextInt() s.nextInt s if(n == 0 && x ==0) break; n == 0 && x ==0 n == 0 n 0 x ==0 x 0 break; int c = 0; c 0 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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            } 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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            } {
                for(int j = i + 1; j <= n; ++j) {
                    for(int k = j + 1; k <= n; ++k) {
                        if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            } for(int j = i + 1; j <= n; ++j) {
                    for(int k = j + 1; k <= n; ++k) {
                        if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                } 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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                } {
                    for(int k = j + 1; k <= n; ++k) {
                        if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                } for(int k = j + 1; k <= n; ++k) {
                        if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    } 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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    } {
                        if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    } if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        } i + j + k == x i + j + k i + j + k i j k x {
                            c++;
                            break;
                        } c++ c break; if(i + j + k > x) {
                            break;
                        } i + j + k > x i + j + k i + j + k i j k x {
                            break;
                        } break; if(i + j * 2 > x) break; i + j * 2 > x i + j * 2 i j * 2 j 2 x break; if(i * 3 > x) break; i * 3 > x i * 3 i 3 x break; System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            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) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    }
}