d = gets.strip.to_i #p d week1 = gets.strip week2 = gets.strip #p week1 #p week2 weeks = week1 + week2 #p weeks def count_max_o(weeks) count_max = 0 count = 0 (0...weeks.length).each do |i| if weeks[i] == 'o' count += 1 else if count > count_max count_max = count end count = 0 end end if count > count_max count_max = count end #p count_max return count_max end count_max = 0 count = 0 i = 0 while i < weeks.length do weeks1 = weeks.clone if weeks[i] == 'o' i += 1 next end (1..d).each do |j| if weeks[i] == 'o' break else weeks1[i] = 'o' end i += 1 end #p weeks1 count = count_max_o(weeks1) if count > count_max count_max = count end i += 1 end p count_max