import java.io.*; import java.util.*; import java.math.*; class Main { public static void out (Object o) { System.out.println(o); } public static int solve (String s , int n) { int ret = 0; int len = s.length(); for (int i = 0; i < len; i++) { int cnt = 0 , j = i; char[] c = s.toCharArray(); while (j < len && cnt < n && c[j] == 'x') { cnt++; c[j++] = 'o'; } //out(Arrays.toString(c)); j = 0; cnt = 0; while (j < len) { while (j < len && c[j] == 'o') { cnt++; j++; } j++; ret = Math.max(ret , cnt); cnt = 0; } } return ret; } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String w1 = br.readLine(); String w2 = br.readLine(); String x = "xxxxxxxxxxxxxx"; out(solve(x + w1 + w2 + x , n)); } }