import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long m = sc.nextLong(); long[] fibo = new long[n + 1]; fibo[1] = 1; fibo[2] = 1; for (int i = 3; i <= n; i++) { fibo[i] = fibo[i - 1] + fibo[i - 2]; } long diff = fibo[n] - m; if (diff < 0) { System.out.println(-1); return; } int count = 0; for (int i = n - 2; i >= 0 && diff > 0; i--) { if (diff >= fibo[i]) { count++; diff -= fibo[i]; } } if (diff > 0) { System.out.println(-1); } else { System.out.println(count); } } }