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

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    }
} import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader 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 line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line; line while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        } String[] input = line.split(" "); input line.split(" ") line.split line " " int max = Integer.valueOf(input[0]); max Integer.valueOf(input[0]) Integer.valueOf Integer input[0] input 0 int goal = Integer.valueOf(input[1]); goal Integer.valueOf(input[1]) Integer.valueOf Integer input[1] input 1 if(max == 0 && goal == 0) break; max == 0 && goal == 0 max == 0 max 0 goal == 0 goal 0 break; int count = 0; count 0 for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            } int i = 1; int i = 1; i 1 i <= max i max i++ i++ i {
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            } {
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            } for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                } int j = 1; int j = 1; j 1 j <= max j max j++ j++ j {
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                } {
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                } if(i == j) continue; i == j i j continue; for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    } int k = 1; int k = 1; k 1 k <= max k max k++ k++ k {
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    } {
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    } if(i == k || j == k) continue; i == k || j == k i == k i k j == k j k continue; if((i+j+k) == goal) count++; (i+j+k) == goal (i+j+k) i+j+k i j k goal count++ count System.out.println(count/6) System.out.println System.out System System.out count/6 count 6 String[] args args public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    }
} public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    }
} Main
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    }
}