#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; int main() { ll n, m; cin >> n >> m; vector fib(n, 1); for (int i = 2; i < n; ++i) { fib[i] = fib[i-1] + fib[i-2]; } m = fib.back()-m; int ans = 0; for (int j = n-3; j >= 0; --j) { if(m >= fib[j]) m -= fib[j], ans++; } if(m) puts("-1"); else cout << ans << "\n"; return 0; }