import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); long[] arr = new long[5]; for (int i = 4; i >= 0; i--) { arr[i] = sc.nextLong(); } long prepre = 1; long pre = 1; TreeSet fibo = new TreeSet<>(); fibo.add(pre); while (pre <= 1000000000000000L) { long x = pre + prepre; fibo.add(x); prepre = pre; pre = x; } int ans = 0; if (fibo.contains(arr[0])) { ans++; } else { System.out.println(0); return; } int start = 1; if (arr[0] == 1 && arr[1] == 1) { start++; ans++; } for (int i = start; i < 5; i++) { if (fibo.higher(arr[i - 1]) != arr[i]) { break; } ans++; } System.out.println(ans); } }