from collections import deque
n, k = map(int, input().split())
MAX = 100001
time = [0] * MAX
cnt = 0
def dfs():
global cnt
q = deque()
q.append(n)
while q:
v = q.popleft()
if v == k:
cnt += 1
for next in (v - 1, v + 1, v * 2):
if 0 <= next < MAX:
if time[next] >= time[v] + 1 or not time[next]:
time[next] = time[v] + 1
q.append(next)
dfs()
print(time[k])
print(cnt)