import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long[] a = new long[5]; for (int i = 0; i < a.length; i++) { a[4 - i] = Long.parseLong(br.readLine()); } br.close(); long f1 = 0; long f2 = 1; int i = 0; int ans = 0; if (a[0] == 1) { ans++; i++; } while (i < 5) { long n = f1 + f2; if (n == a[i]) { ans++; i++; } else if (ans > 0 || n > a[i]) { break; } f1 = f2; f2 = n; } System.out.println(ans); } }