import java.util.Scanner; public class Yuki204{ public static void main(String[] arg){ Scanner sc = new Scanner(System.in); int d,res = 0; String[] week0 = new String[2]; String week; int[] hol = new int[14]; boolean use = false; d = sc.nextInt(); week0[0] = sc.next(); week0[1] = sc.next(); week = week0[0] + week0[1]; for(int i = 0;i<14;i++){ int h = 0; for(int j = 0;j<14-i;j++){ if(week.charAt(i+j)=='o'){ h++; }else{ if(use == false){ h += d; j += d-1; use = true; }else{ break; } } } hol[i] = h; use = false; } for(int i = 0;i<14;i++){ if(hol[i]>res)res = hol[i]; } System.out.println(res); } }