import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int d = sc.nextInt(); char s1[] = sc.next().toCharArray(); char s2[] = sc.next().toCharArray(); char cal[] = new char[42]; Arrays.fill(cal, 'x'); for (int i = 14; i < 21; i++) { cal[i] = s1[i - 14]; } for (int i = 21; i < 28; i++) { cal[i] = s2[i - 21]; } char[] tmp; int cnt, max = 0; for (int i = 0; i <= 42 - d; i++) { tmp = Arrays.copyOf(cal, cal.length); cnt = 0; for (int j = i; j < d + i; j++) { if(tmp[j] == 'o') { break; } tmp[j] = 'o'; } for (int j = 0; j < 42; j++) { if (tmp[j] == 'o') { cnt++; max = Math.max(max, cnt); } else { cnt = 0; } } } System.out.println(max); } }