using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ long[] Fib = new long[N+1]; Fib[1] = 1; Fib[2] = 1; for(int i = 2;i<=N;i++){ Fib[i] = Fib[i-1] + Fib[i-2]; } long rem = Fib[N] - M; int cnt = 0; if( rem < 0 ){ Console.WriteLine(-1); return; } for(int i=N-2;i>=1;i--){ if( rem < Fib[i]) continue; rem -= Fib[i]; cnt++; if(rem == 0) break; } if( rem != 0) { Console.WriteLine(-1); return; } Console.WriteLine(cnt); } int N; long M; public Sol(){ var ss = rsa(); N = int.Parse(ss[0]); M = long.Parse(ss[1]); } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(){return Console.ReadLine().Split(' ');} static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }