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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
} 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 br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str[]; str int n n x x count; count StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        } true {
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        } str = br.readLine().split(" ") str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " n = Integer.parseInt(str[0]) n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 x = Integer.parseInt(str[1]) x Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(n==0 && x==0) break; n==0 && x==0 n==0 n 0 x==0 x 0 break; count = 0 count 0 for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            } int i=1; int i=1; i 1 i<=n-2 i n-2 n 2 i++ i++ i {
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            } {
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            } for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                } int j=i+1; int j=i+1; j i+1 i 1 j<=n-1 j n-1 n 1 j++ j++ j {
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                } {
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                } int k = x - i - j; k x - i - j x - i - j x i j if(j < k && k <= n) count++; j < k && k <= n j < k j k k <= n k n count++ count sb.append(count).append("\n") sb.append(count).append sb.append(count) sb.append sb count "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
} 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 br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
}