Tanechka is shopping in the toy shop. There are exactly n toys in the shop for sale, the cost of the i-th toy is i burles. She wants to choose two toys in such a way that their total cost is k burles. How many ways to do that does she have?

Each toy appears in the shop exactly once. Pairs (a, b) and (b, a) are considered equal. Pairs (a, b), where a=b, are not allowed.

Input

The first line of the input contains two integers n, k (1 ≤ n, k ≤ 10^{14}) — the number of toys and the expected total cost of the pair of toys.

Output

Print the number of ways to choose the pair of toys satisfying the condition above. Print 0, if Tanechka can choose no pair of toys in such a way that their total cost is k burles.

Examples

Input

8 5


Output

2


Input

8 15


Output

1


Input

7 20


Output

0


Input

1000000000000 1000000000001


Output

500000000000

Note

In the first example Tanechka can choose the pair of toys (1, 4) or the pair of toys (2, 3).

In the second example Tanechka can choose only the pair of toys (7, 8).

In the third example choosing any pair of toys will lead to the total cost less than 20. So the answer is 0.

In the fourth example she can choose the following pairs: (1, 1000000000000), (2, 999999999999), (3, 999999999998), ..., (500000000000, 500000000001). The number of such pairs is exactly 500000000000.
/**
 * Created by Baelish on 8/17/2018.
 */

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class B {
    public static void main(String[] args)throws Exception {
        FastReader in = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        long n = in.nextLong(), k = in.nextLong();
        if(n <= (int)1e7) pw.println(brute(n, k));
        else{
            long a = (k/2) + 1, b = k-1;
            long ans = 0;
            if(n >= b) ans = (b-a)+1;
            else if(n >= a) ans = (n-a)+1;
            pw.println(ans);
        }

        pw.close();
    }

    static long brute(long n, long k){
        long ans = 0;
        for (long i = 1; i <= n; i++) {
            long j = k - i;
            if(j > i && j <= n) ans++;
        }
        return ans;
    }

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;
        static final int ints[] = new int[128];

        public FastReader(InputStream is){
            for(int i='0';i<='9';i++) ints[i]=i-'0';
            this.is = is;
        }

        public int readByte(){
            if(lenbuf == -1)throw new InputMismatchException();
            if(ptrbuf >= lenbuf){
                ptrbuf = 0;
                try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
                if(lenbuf <= 0)return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }
        public int skip() {
            int b;
            while((b = readByte()) != -1 && isSpaceChar(b));
            return b;
        }

        public String next(){
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt(){
            int num = 0, b;
            boolean minus = false;
            while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
            if(b == '-'){
                minus = true;
                b = readByte();
            }

            while(true){
                if(b >= '0' && b <= '9'){
                    num = (num<<3) + (num<<1) + ints[b];
                }else{
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
            if(b == '-'){
                minus = true;
                b = readByte();
            }

            while(true){
                if(b >= '0' && b <= '9'){
                    num = (num<<3) + (num<<1) + ints[b];
                }else{
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
       /* public char nextChar() {
            return (char)skip();
        }*/

        public char[] next(int n){
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while(p < n && !(isSpaceChar(b))){
                buf[p++] = (char)b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        /*private char buff[] = new char[1005];
        public char[] nextCharArray(){
            int b = skip(), p = 0;
            while(!(isSpaceChar(b))){
                buff[p++] = (char)b;
                b = readByte();
            }
            return Arrays.copyOf(buff, p);
        }*/
    }
}