import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B
 * @author wsKmatsuda
 *
 */
public class Main{

	public static void main(String[] args) {

		new Main().run();

	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ThreeNumberTotalCheck?????????
	 * n???x?????????????????????
	 * 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°????±???????
	 */
	class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util public class Main{

	public static void main(String[] args) {

		new Main().run();

	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ThreeNumberTotalCheck?????????
	 * n???x?????????????????????
	 * 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°????±???????
	 */
	class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	}

} Main public static void main(String[] args) {

		new Main().run();

	} main {

		new Main().run();

	} new Main().run() new Main().run new Main() String[] args args public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	} run {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String inputData; inputData List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>(); testDataList new ArrayList<ThreeNumberTotalCheck>() try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        } true {
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        } inputData = reader.readLine() inputData reader.readLine() reader.readLine reader if("0 0".equals(inputData)){
					break;
				} "0 0".equals(inputData) "0 0".equals "0 0" inputData {
					break;
				} break; String[] strData = inputData.split(" "); strData inputData.split(" ") inputData.split inputData " " int n = Integer.parseInt(strData[0]); n Integer.parseInt(strData[0]) Integer.parseInt Integer strData[0] strData 0 int x = Integer.parseInt(strData[1]); x Integer.parseInt(strData[1]) Integer.parseInt Integer strData[1] strData 1 testDataList.add(new ThreeNumberTotalCheck(n,x)) testDataList.add testDataList new ThreeNumberTotalCheck(n,x) for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        } ThreeNumberTotalCheck result testDataList {
	        	System.out.println(result.getCnt());
	        } {
	        	System.out.println(result.getCnt());
	        } System.out.println(result.getCnt()) System.out.println System.out System System.out result.getCnt() result.getCnt result class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	} ThreeNumberTotalCheck //check limit
		public int n; n //total
		public int x; x //1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt; cnt public String evalution; evalution ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		} ThreeNumberTotalCheck {
			n = _n;
			x = _x;

			setCnt();

		} n = _n n _n x = _x x _x setCnt() setCnt int _n _n int _x _x /**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		} setCnt {
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		} cnt = 0 cnt 0 for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			} 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;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			} {
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			} for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				} int j=i+1; int j=i+1; j i+1 i 1 j<n j n j++ j++ j {
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				} {
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				} int jg = x - i - j; jg x - i - j x - i - j x i j if(jg > j && jg <= n){
						cnt++;
					} jg > j && jg <= n jg > j jg j jg <= n jg n {
						cnt++;
					} cnt++ cnt /**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		} getCnt {

			return cnt;

		} return cnt; cnt public class Main{

	public static void main(String[] args) {

		new Main().run();

	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ThreeNumberTotalCheck?????????
	 * n???x?????????????????????
	 * 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°????±???????
	 */
	class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	}

} public class Main{

	public static void main(String[] args) {

		new Main().run();

	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ThreeNumberTotalCheck?????????
	 * n???x?????????????????????
	 * 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°????±???????
	 */
	class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B
 * @author wsKmatsuda
 *
 */
public class Main{

	public static void main(String[] args) {

		new Main().run();

	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<ThreeNumberTotalCheck> testDataList = new ArrayList<ThreeNumberTotalCheck>();

        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
				if("0 0".equals(inputData)){
					break;
				}
				String[] strData = inputData.split(" ");
				int n = Integer.parseInt(strData[0]);
				int x = Integer.parseInt(strData[1]);
				testDataList.add(new ThreeNumberTotalCheck(n,x));

	        }

	        //????????????
	        for(ThreeNumberTotalCheck result :testDataList){
	        	System.out.println(result.getCnt());
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ThreeNumberTotalCheck?????????
	 * n???x?????????????????????
	 * 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°????±???????
	 */
	class ThreeNumberTotalCheck{

		//check limit
		public int n;
		//total
		public int x;
		//1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°
		public int cnt;

		public String evalution;

		ThreeNumberTotalCheck(int _n ,int _x){
			n = _n;
			x = _x;

			setCnt();

		}

		/**
		 * ??¶??°?????????
		 */
		private void setCnt(){
			cnt = 0;

			for(int i=1;i<n+2;i++){
				for(int j=i+1;j<n;j++){
					int jg = x - i - j;
					//System.out.println(i + "," + j + "," + jg + "=" +(i+j+jg));
					if(jg > j && jg <= n){
						cnt++;
					}

				}

				/*
				1-2-3
				1-2-4
				1-2-5

				1-3-4
				1-3-5

				1-4-5

				2-3-4
				2-3-5

				2-4-5

				3-4-5
				*/
			}
		}

		/**
		 * ??¶??°?????????
		 * @return
		 */
		public int getCnt(){

			return cnt;

		}
	}

}