#include #include using namespace std; int main() { int n; long long m; cin >> n >> m; vector dp(n); dp[0] = 1; dp[1] = 1; for (int i = 2; i < n; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } if (dp[n - 1] == m) { cout << 0 << endl; } else if (dp[n - 1] < m) { cout << -1 << endl; } else { long long diff = dp[n - 1] - m; int count = 0; for (int i = n - 3; i >= 0; i--) { if (diff >= dp[i]) { diff -= dp[i]; count++; if (diff == 0) { cout << count << endl; break; } } } } return 0; }