#include <bits/stdc++.h>
using namespace std;
int n,k,ans=100002;
int dist[140'002];
int cnt;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
queue<int> q;
q.push(n);
dist[n] = 1;
while(!q.empty()){
int x = q.front(); q.pop();
if(dist[x] >= ans) continue;
for(int nx:{2*x,x-1,x+1}){
if(nx<0||nx>140000) continue;
if(dist[nx] && dist[nx] < dist[x] + 1) continue;
dist[nx] = dist[x]+1;
if(nx==k){
ans = dist[nx];
cnt++;
continue;
}
q.push(nx);
}
}
if(ans == 100002){
cout << 0 << '\n' << 1;
}else cout << ans-1 << '\n' << cnt;
}