d = gets.chomp.to_i c1 = gets.chomp c2 = gets.chomp c = c1 + c2 max_day = 0 def count_max_day(weeks) count_max_day = 0 count_day = 0 weeks.each_char do |day| if day == 'x' count_day = 0 else count_day += 1 count_max_day = [count_day, count_max_day].max end end count_max_day end max_day = 0 weeks = ('o' * d) + c #puts weeks max_day = [count_max_day(weeks), max_day].max #p max_day weeks = c + ('o' * d) #puts weeks #p max_day max_day = [count_max_day(weeks), max_day].max (0...(c.length-d)).each do |i| count_day = 0 weeks = c[0, i] + ("o" * d) + c[i + d..-1] max_day = [count_max_day(weeks), max_day].max end puts max_day