package yukicoder; import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } long[] fibo; void solve(){ Scanner sc=new Scanner(System.in); fibo=new long[81];fibo[1]=1;fibo[2]=1; for(int i=3;i<=80;i++)fibo[i]=fibo[i-1]+fibo[i-2]; tr(fibo); int n=sc.nextInt(); long m=sc.nextLong(); m=fibo[n]-m; int count=0; for(long i=n-2;i>=1;i--){ if(fibo[(int)i]<=m){ m-=fibo[(int)i]; count++; } if(m==0)break; } if(m!=0)System.out.println(-1); else System.out.println(count); } void tr(Object...o){System.out.println(Arrays.deepToString(o));} }