import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final long M = sc.nextLong(); long[] fibs = new long[N]; fibs[0] = fibs[1] = 1; for(int i = 2; i < N; i++){ fibs[i] = fibs[i - 1] + fibs[i - 2]; } if(fibs[N - 1] < M){ System.out.println(-1); return; } // 貪欲で良い理由がよく分からない。 long remain = fibs[N - 1] - M; int count = 0; for(int i = N - 2; i >= 0; i--){ if(remain >= fibs[i]){ //System.out.printhln(remain + " " + fibs[i]); remain -= fibs[i]; count++; } } System.out.println(count); } }