#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
int f[1005][1005];
inline int dfs(int a, int b)
{
if(f[a][b] != -1)
return f[a][b];
int ans = 0;
f[a][b] = 1e9;
for(int i = 1; i <= b; ++i)
{
ans = max(dfs(a-1,i-1),dfs(a,b-i));
f[a][b] = min(ans+1,f[a][b]);
}
return f[a][b];
}
int main()
{
freopen("eagleegg.in", "r", stdin);
freopen("eagleegg.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
memset(f,-1,sizeof(f));
for(int i = 0; i <= 1000; ++i)
f[1][i] = i;
for(int i = 0; i <= 1000; ++i)
f[i][0] = 0;
while(cin >> n >> m)
{
if(n == 0 && m == 0)
break;
cout << dfs(n,m) << '\n';
}
return 0;
}