#include using namespace std; #define REP(i,a,b) for(i=a;i'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} template void reader(T *x, S *y){reader(x);reader(y);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} template void writerLn(T x){writer(x,'\n');} ll N, M; ll fib[100]; int main(){ int i, res = 0; reader(&N,&M); fib[1] = fib[2] = 1; REP(i,3,N+1) fib[i] = fib[i-1] + fib[i-2]; M = fib[N] - M; for(i=N-2;i;i--) if(M >= fib[i]) M -= fib[i], res++; if(M) res=-1; writerLn(res); return 0; }