#include using namespace std; long long fib[80+1]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); fib[0] = 0; fib[1] = 1; for (int i = 2; i <= 80; i++) fib[i] = fib[i-1] + fib[i-2]; int n; long long m; cin >> n >> m; if (m > fib[n]) cout << -1 << endl; else if (m == fib[n]) cout << 0 << endl; else { long long x = fib[n] - m; int ret = 0; for (int i = n-2; i > 0; i--) { if (x >= fib[i]) { ++ret; x -= fib[i]; } } if (x == 0) cout << ret << endl; else cout << -1 << endl; } return 0; }