def fibo(n): f = [0, 1] for i in range(n-1): f.append(f[-1] + f[-2]) return f def split(n, f): f = f[::-1] s = [] for m in f[2:]: if m <= n: s.append(m) n -= m if n == 0: return s def solve(n, m): f = fibo(n) d = f[-1] - m if d < 0: return -1 elif d == 0: return 0 else: return len(split(d, f)) n, m = map(int, input().strip().split(' ')) print(solve(n, m))