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 l: usize = 0; let mut r: usize = fib.len(); while r > l + 1 { let mid = (l + r) / 2; if v[4] < fib[mid] { r = mid; } else { l = mid; } } if v[4] == 1 { l = 1; if v[3] == 1 { l = 0; } } for &i in v.iter().rev() { if i == fib[l] { ans += 1; l += 1; } } println!("{}", ans); }