#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    long long m;
    cin >> n >> m;

    vector<long long> a(n, 1);
    for(int i=2; i<n; ++i)
        a[i] = a[i-1] + a[i-2];

    long long x = a[n-1] - m;
    int ans = 0;
    for(int i=n-3; i>=0; --i){
        if(x >= a[i]){
            x -= a[i];
            ++ ans;
        }
    }

    if(x == 0)
        cout << ans << endl;
    else
        cout << -1 << endl;

    return 0;
}