#include <bits/stdc++.h>

using namespace std;
typedef signed long long ll;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
 
const double INF = 1e10;

long N, M;
long F[100];
 
int main() {
  cin >> N >> M;
  F[0] = 0;
  F[1] = 1;

  FOR(i, 2, N + 1) {
    F[i] = F[i - 1] + F[i - 2];
  }

  long d = F[N] - M;

  int ans = 0;
  if (d < 0) {
    ans = -1;
  }
  else if (d == 0) {
    ans = 0;
  }
  else if (d > F[N]) {
    ans = -1;
  }
  else {
    // F[1] から F[N-2] までの部分和で d を表す
    RFOR(i, 1, N-1) {
      if (F[i] <= d) {
        d -= F[i];
        ans++;
      }
    }
    if (d != 0) {
      ans = -1;
    }
  }

  cout << ans << endl;
  return 0;
}