D = input() cal = raw_input() + raw_input() def max_successive_holidays(cal): cal = cal.split('x') holidays = [len(item) for item in cal] return max(holidays) max_holidays = 0 for i in xrange(14-D): cal_days_off = list(cal) cal_days_off[i:i+D] = ['o'] * D cal_days_off = ''.join(cal_days_off) max_holidays = max(max_successive_holidays(cal_days_off), max_holidays) print max_holidays