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