#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; long long fibonacci(int n){ vector a(n + 1, 1); for(int i = 3; i <= n; ++i)a[i] = a[i - 1] + a[i - 2]; return a[n]; } int main(){ int N; ll M; while(cin >> N >> M){ ll fib = fibonacci(N); ll fusoku = fib - M; if(fusoku < 0){ puts("-1"); } else{ int cnt = 0; for(int i = 3; i <= N && fusoku > 0; ++i){ ll a = fibonacci(N + 1 - i); if(fusoku >= a){ cnt++; fusoku -= a; } } if(fusoku == 0){ cout << cnt << endl; } else{ puts("-1"); } } } }