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.
	                            import java.io.BufferedReader;
	import java.io.IOException;
	import java.io.InputStream;
	import java.io.InputStreamReader;
	import java.io.PrintWriter;
	import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
	import java.util.InputMismatchException;
	import java.util.Iterator;
	import java.util.LinkedList;
	import java.util.TreeSet;
	
	
	
	                                            public class Solution1 implements Runnable
	                                            {
	                                                static final long MAX = 464897L;
	                                                static class InputReader
	                                                {
	                                                    private InputStream stream;
	                                                    private byte[] buf = new byte[1024];
	                                                    private int curChar;
	                                                    private int numChars;
	                                                    private SpaceCharFilter filter;
	                                                    private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	                                             
	                                                    public InputReader(InputStream stream)
	                                                    {
	                                                        this.stream = stream;
	                                                    }
	                                                    
	                                                    public int read()
	                                                    {
	                                                        if (numChars==-1) 
	                                                            throw new InputMismatchException();
	                                                        
	                                                        if (curChar >= numChars)
	                                                        {
	                                                            curChar = 0;
	                                                            try 
	                                                            {
	                                                                numChars = stream.read(buf);
	                                                            }
	                                                            catch (IOException e)
	                                                            {
	                                                                throw new InputMismatchException();
	                                                            }
	                                                            
	                                                            if(numChars <= 0)                
	                                                                return -1;
	                                                        }
	                                                        return buf[curChar++];
	                                                    }
	                                                 
	                                                    public String nextLine()
	                                                    {
	                                                        String str = "";
	                                                        try
	                                                        {
	                                                            str = br.readLine();
	                                                        }
	                                                        catch (IOException e)
	                                                        {
	                                                            e.printStackTrace();
	                                                        }
	                                                        return str;
	                                                    }
	                                                    public int nextInt()
	                                                    {
	                                                        int c = read();
	                                                        
	                                                        while(isSpaceChar(c)) 
	                                                            c = read();
	                                                        
	                                                        int sgn = 1;
	                                                        
	                                                        if (c == '-') 
	                                                        {
	                                                            sgn = -1;
	                                                            c = read();
	                                                        }
	                                                        
	                                                        int res = 0;
	                                                        do 
	                                                        {
	                                                            if(c<'0'||c>'9') 
	                                                                throw new InputMismatchException();
	                                                            res *= 10;
	                                                            res += c - '0';
	                                                            c = read();
	                                                        }
	                                                        while (!isSpaceChar(c)); 
	                                                        
	                                                        return res * sgn;
	                                                    }
	                                                    
	                                                    public long nextLong() 
	                                                    {
	                                                        int c = read();
	                                                        while (isSpaceChar(c))
	                                                            c = read();
	                                                        int sgn = 1;
	                                                        if (c == '-') 
	                                                        {
	                                                            sgn = -1;
	                                                            c = read();
	                                                        }
	                                                        long res = 0;
	                                                        
	                                                        do 
	                                                        {
	                                                            if (c < '0' || c > '9')
	                                                                throw new InputMismatchException();
	                                                            res *= 10;
	                                                            res += c - '0';
	                                                            c = read();
	                                                        }
	                                                        while (!isSpaceChar(c));
	                                                            return res * sgn;
	                                                    }
	                                                    
	                                                    public double nextDouble() 
	                                                    {
	                                                        int c = read();
	                                                        while (isSpaceChar(c))
	                                                            c = read();
	                                                        int sgn = 1;
	                                                        if (c == '-') 
	                                                        {
	                                                            sgn = -1;
	                                                            c = read();
	                                                        }
	                                                        double res = 0;
	                                                        while (!isSpaceChar(c) && c != '.') 
	                                                        {
	                                                            if (c == 'e' || c == 'E')
	                                                                return res * Math.pow(10, nextInt());
	                                                            if (c < '0' || c > '9')
	                                                                throw new InputMismatchException();
	                                                            res *= 10;
	                                                            res += c - '0';
	                                                            c = read();
	                                                        }
	                                                        if (c == '.') 
	                                                        {
	                                                            c = read();
	                                                            double m = 1;
	                                                            while (!isSpaceChar(c)) 
	                                                            {
	                                                                if (c == 'e' || c == 'E')
	                                                                    return res * Math.pow(10, nextInt());
	                                                                if (c < '0' || c > '9')
	                                                                    throw new InputMismatchException();
	                                                                m /= 10;
	                                                                res += (c - '0') * m;
	                                                                c = read();
	                                                            }
	                                                        }
	                                                        return res * sgn;
	                                                    }
	                                                    
	                                                    public String readString() 
	                                                    {
	                                                        int c = read();
	                                                        while (isSpaceChar(c))
	                                                            c = read();
	                                                        StringBuilder res = new StringBuilder();
	                                                        do 
	                                                        {
	                                                            res.appendCodePoint(c);
	                                                            c = read();
	                                                        } 
	                                                        while (!isSpaceChar(c));
	                                                        
	                                                        return res.toString();
	                                                    }
	                                                 
	                                                    public boolean isSpaceChar(int c) 
	                                                    {
	                                                        if (filter != null)
	                                                            return filter.isSpaceChar(c);
	                                                        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	                                                    }
	                                                 
	                                                    public String next() 
	                                                    {
	                                                        return readString();
	                                                    }
	                                                    
	                                                    public interface SpaceCharFilter 
	                                                    {
	                                                        public boolean isSpaceChar(int ch);
	                                                    }
	                                                }
	                                                 
	                                                public static void main(String args[]) throws Exception
	                                                {
	                                                    new Thread(null, new Solution1(),"Solution",1<<26).start();
	                                                }    
	                                                public static int gcd(int a, int b)
	                                                {
	                                                    if (a == 0)
	                                                        return b;
	                                                     
	                                                    return gcd(b%a, a);
	                                                }
	                                                int lcm(int a, int b)
	                                                {
	                                                    return (a*b)/gcd(a, b);
	                                                }
	                                                ArrayList<Integer> adj[];
	                                                static long MOD = 1000000007;
	                                                int[] dx = {1,-1,0,0};
	                                                int[] dy = {0,0,1,-1};
	                                                int MAXN = 1000005;
	                                                HashSet<Pair> hset = new HashSet();
	                                                
	                                                
	                                                int count  = 0;
	                                                int[] arr;
	                                                public void run() 
	                                                {
	                                                    
	                                                        //InputReader sc= new InputReader(new FileInputStream("input.txt"));
	                                                        //PrintWriter w= new PrintWriter(new FileWriter("output.txt"));
	                                                        InputReader sc = new InputReader(System.in);
	                                                        PrintWriter w = new PrintWriter(System.out);
	                                                        long a = sc.nextLong();
	                                                        long b = sc.nextLong();
	                                                        if(b <= a) {
	                                                        	w.println((b - 1)/2);
	                                                        }else {
	                                                        	if(b - a > a) {
	                                                        		w.println("0");
	                                                        	}else {
	                                                        		long one = a;
	                                                        		long two = b - a;
	                                                        		w.println((one - two + 1)/2);
	                                                        	}
	                                                        }
	                                                        w.close();                                                                
	                                                 }
	                                                static class Pair implements Comparable<Pair>{
	                                                    int a;
	                                                    int b;
	                                                    
	                                                    
	                                                    Pair(int a,int b){
	                                                        this.a  =a;
	                                                        this.b = b;
	                                                        
	                                                    }
	                                                    Pair(){}    
	                                                    public boolean equals(Object o)
	                                                    {
	                                                        Pair p = (Pair)o;
	                                                        return this.a == p.a && this.b == p.b;
	                                                    }
	                                                    
	                                                    public int compareTo(Pair p){
	                                                        
	                                                        return Long.compare(this.b,p.b);
	                                                    }
	                                                    public int hashCode()
	                                                    {
	                                                        return new Long(a).hashCode()*31 + new Long(b).hashCode()*2 + new Long(a).hashCode() * 3;
	                                                    }
	
	                                                }
	                                                
	                                }