#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long int m; int n; long long int a; long long int b; vector v; map dp[82]; __int128 sum[82]; inline long long int dfs(int b, unsigned long long int val){ if (b < 0){ if (val == 0LL){ return 0; } return -1; } int ans1 = -1; int ans2 = -1; if (val >= v[b]){ ans1 = dfs(b - 1, val - v[b]); } if (ans1 != -1){ ans1++; } ans2 = dfs(b - 1, val); if (ans2 >= 0){ if (ans1 == -1 || ans1 > ans2){ ans1 = ans2; } } return ans1; } int main(){ scanf("%d", &n); scanf("%lld", &m); a = 1; b = 1; v.push_back(1); v.push_back(1); sum[0] = 1; sum[1] = 1; for (int i = 2; i < n; i++){ swap(a, b); b += a; v.push_back(b); sum[v.size() - 1] = (__int128)(sum[v.size() - 2]) + (__int128)(b); } v.pop_back(); v.pop_back(); unsigned long long int need = b - m; int ans = dfs(v.size() - 1, need); printf("%d\n", ans); return 0; }