import math

N, M = map(int, raw_input().split())

A = [0] * 85
A[1] = 1
A[2] = 1
for i in xrange(3, 81):
  A[i] = A[i - 1] + A[i - 2]

i = N-2
ans = 0
diff = A[N] - M
while i >= 1 and diff > 0:
  if diff - A[i] >= 0:
    diff -= A[i]
    ans += 1
  i -= 1
if diff != 0:
  print -1
else:
  print ans