import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.stream.Stream;

import java.util.Set;
import java.util.HashSet;

public class Main {

    private static Set<String> ans;
    private static ArrayList<Integer> arr;

    private static void hasArrayTwoCandidates(ArrayList<Integer> a, int arSize, int sum, int x) {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    }

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.stream.Stream; Stream java.util.stream import java.util.Set; Set java.util import java.util.HashSet; HashSet java.util public class Main {

    private static Set<String> ans;
    private static ArrayList<Integer> arr;

    private static void hasArrayTwoCandidates(ArrayList<Integer> a, int arSize, int sum, int x) {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    }

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
} Main private static Set<String> ans; ans private static ArrayList<Integer> arr; arr private static void hasArrayTwoCandidates(ArrayList<Integer> a, int arSize, int sum, int x) {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    } hasArrayTwoCandidates {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    } Integer l = 0; l 0 Integer r = arSize - 1; r arSize - 1 arSize 1 while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	} l<r l r {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	} if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    } a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum) a.get(l)!=(x-sum) a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum) a.get(l) + a.get(r) == sum a.get(l) + a.get(r) a.get(l) a.get a l a.get(r) a.get a r sum a.get(l)!=a.get(r) a.get(l) a.get a l a.get(r) a.get a r a.get(l)!=(x-sum) a.get(l) a.get a l (x-sum) x sum a.get(r)!=(x-sum) a.get(r) a.get a r (x-sum) x sum {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } arr = null arr null arr = new ArrayList<Integer>() arr new ArrayList<Integer>() arr.add(x - sum) arr.add arr x - sum x sum arr.add(a.get(l)) arr.add arr a.get(l) a.get a l arr.add(a.get(r)) arr.add arr a.get(r) a.get a r Collections.sort(arr) Collections.sort Collections arr ans.add(arr.toString()) ans.add ans arr.toString() arr.toString arr l++ l if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    } a.get(l) + a.get(r) < sum a.get(l) + a.get(r) a.get(l) a.get a l a.get(r) a.get a r sum {
		l++;
	    } l++ l {
		r--;
	    } r-- r return; ArrayList<Integer> a a int arSize arSize int sum sum int x x public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    } main {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    } try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	} Exception e {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	} System.out.println(e.getMessage()) System.out.println System.out System System.out e.getMessage() e.getMessage e System.out.println(Arrays.toString(e.getStackTrace())) System.out.println System.out System System.out Arrays.toString(e.getStackTrace()) Arrays.toString Arrays e.getStackTrace() e.getStackTrace e System.exit(0) System.exit System 0 {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) List<String> lines = new ArrayList<String>(); lines new ArrayList<String>() String line = ""; line "" while((line = br.readLine()) != null){
	    lines.add(line);
	    } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
	    lines.add(line);
	    } lines.add(line) lines.add lines line br.close() br.close br for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    } String e lines {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    } {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    } if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		} e.equals("0 0") e.equals e "0 0" {
		    break;
		} break; {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		} int initial = Integer.parseInt(e.split(" ")[0]); initial Integer.parseInt(e.split(" ")[0]) Integer.parseInt Integer e.split(" ")[0] e.split(" ") e.split e " " 0 ArrayList<Integer> n = new ArrayList<Integer>(); n new ArrayList<Integer>() for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    } Integer i = 1; Integer i = 1; i 1 i < initial+1 i initial+1 initial 1 i++ i++ i {
			n.add(i);
		    } {
			n.add(i);
		    } n.add(i) n.add n i Integer x = Integer.parseInt(e.split(" ")[1]); x Integer.parseInt(e.split(" ")[1]) Integer.parseInt Integer e.split(" ")[1] e.split(" ") e.split e " " 1 ans = null ans null ans = new HashSet<String>() ans new HashSet<String>() for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    } Integer t n {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    } {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    } hasArrayTwoCandidates(n, n.size(), x - t, x) hasArrayTwoCandidates n n.size() n.size n x - t x t x System.out.println(ans.size()) System.out.println System.out System System.out ans.size() ans.size ans System.exit(0) System.exit System 0 String[] args args public class Main {

    private static Set<String> ans;
    private static ArrayList<Integer> arr;

    private static void hasArrayTwoCandidates(ArrayList<Integer> a, int arSize, int sum, int x) {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    }

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
} public class Main {

    private static Set<String> ans;
    private static ArrayList<Integer> arr;

    private static void hasArrayTwoCandidates(ArrayList<Integer> a, int arSize, int sum, int x) {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    }

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.stream.Stream;

import java.util.Set;
import java.util.HashSet;

public class Main {

    private static Set<String> ans;
    private static ArrayList<Integer> arr;

    private static void hasArrayTwoCandidates(ArrayList<Integer> a, int arSize, int sum, int x) {
	Integer l = 0;
	Integer r = arSize - 1;

	while (l<r) {
	    if (a.get(l) + a.get(r) == sum &&
		a.get(l)!=a.get(r) &&
		a.get(l)!=(x-sum)  &&
		a.get(r)!=(x-sum)
		) {
		arr = null;
		arr = new ArrayList<Integer>();
		arr.add(x - sum);
		arr.add(a.get(l));
		arr.add(a.get(r));
		Collections.sort(arr);
		ans.add(arr.toString());
		//System.out.println(arr.toString());
		l++;
	    } else if (a.get(l) + a.get(r) < sum) {
		l++;
	    } else {
		r--;
	    }
	}
	return;
    }

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    lines.add(line);
	    }
	    br.close();

	    //lines.add("5 9");
	    //lines.add("0 0");
	    //lines.add("100 100");
	    //lines.add("100 200");
	    //lines.add("100 297");
	    //lines.add("0 0");

	    for (String e:lines) {
		if (e.equals("0 0")) {
		    break;
		} else {
		    int initial = Integer.parseInt(e.split(" ")[0]);
		    ArrayList<Integer> n = new ArrayList<Integer>();
		    for (Integer i = 1; i < initial+1; i++) {
			n.add(i);
		    }
		    Integer x = Integer.parseInt(e.split(" ")[1]);

		    ans = null;
		    ans = new HashSet<String>();
		    for (Integer t : n) {
			hasArrayTwoCandidates(n, n.size(), x - t, x);
		    }

		    //for (String ansstr : ans) {
		    // 	System.out.println(ansstr);
		    //};

		    //Collections.sort(ans);
		    System.out.println(ans.size());
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}