思路:简单数学
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
typedef long long ll;
ll n,m,ans;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n >> m;
ll t = m/2;
if( n >= m)
{
if(m%2 == 0)
ans = t-1;
else
ans = t;
}
else
ans = n - t;
if(ans > 0)
cout << ans << endl;
else
cout << 0 << endl;
return 0;
}