use std::io::Read; const MAX: u64 = 1000000000000000; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let v: Vec = (0..5) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut f1: u64 = 0; let mut f2: u64 = 1; let mut fib: Vec = Vec::new(); while f2 < MAX * 2 { fib.push(f2); let tmp = f1; f1 = f2; f2 += tmp; } let mut ans: usize = 0; let mut i: usize = v.len(); while i > 0 { i -= 1; let mut l: usize = 0; let mut r: usize = fib.len(); while r > l + 1 { let mid = (l + r) / 2; if v[i] < fib[mid] { r = mid; } else { l = mid; } } if v[i] != fib[l] { if i == 0 { break; } i -= 1; continue; } if v[i] == 1 { l = 0; } let mut j: usize = i; let mut cnt: usize = 0; while l < fib.len() && fib[l] == v[j] { cnt += 1; l += 1; if j == 0 { break; } j -= 1; } ans = std::cmp::max(ans, cnt); } println!("{}", ans); }