#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include #include //#include #include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; ll fib[82]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; ll M; cin >> N >> M; N--; fib[0] = fib[1] = 1; for (int i = 2; i < 80; i++) { fib[i] = fib[i-1] + fib[i-2]; } if (fib[N] < M) { cout << -1 << endl; return 0; } ll diff = fib[N]-M; int ans = 0; while (diff) { int index = upper_bound(fib, fib+80, diff) - fib - 1; if (N-index <= 1) { cout << -1 << endl; return 0; } ans++; diff -= fib[index]; } cout << ans << endl; return 0; }