#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) #define LONG_INF 100000000000000 long long fib[100] = {}; int main() { long long n, m; cin >> n >> m; fib[1] = 1; fib[2] = 1; for (int i = 3;i <= n;++i) { fib[i] = fib[i - 1] + fib[i - 2]; } if (fib[n] < m) { cout << -1 << endl; return 0; } long long dis = fib[n] - m; int ans = 0; for (int i = n-2;i > 0;--i) { if (dis >= fib[i]) { dis -= fib[i]; ans++; } } if (dis != 0) { cout << -1 << endl; return 0; } cout << ans << endl; return 0; }