import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int count = 0;
	static int[] selectedNum = new int[3];
	static int n;
	static int x;
	
	static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	static int count = 0;
	static int[] selectedNum = new int[3];
	static int n;
	static int x;
	
	static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	}

} Main static int count = 0; count 0 static int[] selectedNum = new int[3]; selectedNum new int[3] 3 static int n; n static int x; x static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	} saiki {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	} if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		} index == selectedNum.length index selectedNum.length selectedNum selectedNum.length {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		} int sum = 0; sum 0 for (int num : selectedNum) {
				sum += num;
			} int num selectedNum {
				sum += num;
			} {
				sum += num;
			} sum += num sum num if (sum == x) {
				count++;
			} sum == x sum x {
				count++;
			} count++ count return; int startNum = 1; startNum 1 if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		} index != 0 index 0 {
			startNum = selectedNum[index-1] + 1;
		} startNum = selectedNum[index-1] + 1 startNum selectedNum[index-1] + 1 selectedNum[index-1] selectedNum index-1 index 1 1 for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		} int i = startNum; int i = startNum; i startNum i <= n i n i++ i++ i {
			selectedNum[index] = i;
			saiki(index + 1);
		} {
			selectedNum[index] = i;
			saiki(index + 1);
		} selectedNum[index] = i selectedNum[index] selectedNum index i saiki(index + 1) saiki index + 1 index 1 int index index public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) List<Integer> answers = new ArrayList<Integer>(); answers new ArrayList<Integer>() while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		} true {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		} n = scan.nextInt() n scan.nextInt() scan.nextInt scan x = scan.nextInt() x scan.nextInt() scan.nextInt scan if (n == 0 && x == 0) {
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; count = 0 count 0 saiki(0) saiki 0 answers.add(count) answers.add answers count for (Integer ans : answers) {
			System.out.println(ans);
		} Integer ans answers {
			System.out.println(ans);
		} {
			System.out.println(ans);
		} System.out.println(ans) System.out.println System.out System System.out ans scan.close() scan.close scan String[] args args public class Main {
	static int count = 0;
	static int[] selectedNum = new int[3];
	static int n;
	static int x;
	
	static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	}

} public class Main {
	static int count = 0;
	static int[] selectedNum = new int[3];
	static int n;
	static int x;
	
	static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int count = 0;
	static int[] selectedNum = new int[3];
	static int n;
	static int x;
	
	static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	}

}