#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define nline cout<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define ain(A, B, C) assert(IN(A, B, C))
#define ull unsigned long long int
#define ll long long int
#define pii pair<int,int>
#define MAXX 100009
#define fr(a,b,i) for(int i=a;i<b;i++)
vector<int>G[MAXX];
ull a,b;
double ans;
map<double,int>dis;
int bfs(double src)
{
queue<double>q;
q.push(src);
dis[src]=1;
while(not q.empty())
{
double s=q.front();
if(abs(s-ans)<1e-6)return dis[s];
double t=(double)((s*1.0)/(s+1.0));
q.push(t);
dis[t]=dis[s]+1;
q.push(s+1);
dis[s+1]=dis[s]+1;
}
}
int main()
{
cin>>a>>b;
ans=(double)((a*1.0)/b);
int anss=bfs(1.0);
cout<<anss<<endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBubGluZSBjb3V0PDwiXG4iCiNkZWZpbmUgZmFzdCBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSxjaW4udGllKDApCiNkZWZpbmUgYWluKEEsIEIsIEMpIGFzc2VydChJTihBLCBCLCBDKSkKI2RlZmluZSB1bGwgdW5zaWduZWQgbG9uZyBsb25nIGludAojZGVmaW5lIGxsIGxvbmcgbG9uZyBpbnQKI2RlZmluZSBwaWkgcGFpcjxpbnQsaW50PgojZGVmaW5lIE1BWFggMTAwMDA5CiNkZWZpbmUgZnIoYSxiLGkpIGZvcihpbnQgaT1hO2k8YjtpKyspCnZlY3RvcjxpbnQ+R1tNQVhYXTsKdWxsIGEsYjsKZG91YmxlIGFuczsKbWFwPGRvdWJsZSxpbnQ+ZGlzOwppbnQgYmZzKGRvdWJsZSBzcmMpCnsKCXF1ZXVlPGRvdWJsZT5xOwoJcS5wdXNoKHNyYyk7Cgl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