li = 5.times.map{gets.to_i}.reverse fb = (1..999).reduce([1,1]){|s,e| s << s[-1]+s[-2];s}.take_while{|e| e <= 10**15} p (5.times.select{|r| fb.each_cons(r+1).include? li[0..r]}.max||-1)+1