#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <complex> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <iomanip> #include <assert.h> #include <array> #include <cstdio> #include <cstring> #include <random> #include <functional> #include <numeric> #include <bitset> using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) #define minimize(a, x) a = std::min<decltype(a)>(a, x) #define maximize(a, x) a = std::max<decltype(a)>(a, x) typedef long long ll; int const inf = 1<<29; ll fib[88]; int main() { ll N, M; cin >> N >> M; fib[1] = fib[2] = 1; REP(i, 3, 88) fib[i] = fib[i-1] + fib[i-2]; ll diff = fib[N] - M; if(diff < 0) { cout << -1 << endl; exit(0); } int res = 0; for(int i=N-2; i>=1; i--) { if(fib[i] <= diff) { diff -= fib[i]; res ++; } } cout << ( !!diff ? -1 : res ) << endl; return 0; }