d = int(input()) week = list(input())+list(input()) maxholi = 0 def search(wek,i,cnt): global maxholi while cnt>0 and i<14: if wek[i]=="o": break wek[i]="o" cnt -= 1 i += 1 cnt = 0 for i in range(14): if wek[i]=="o": cnt += 1 maxholi = max(maxholi,cnt) else: cnt = 0 for i in range(14): if week[i]=="x": search(week[:],i,d) search(week,0,0) print(maxholi)