import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int D = sc.nextInt(); String string = sc.next() + sc.next(); string = string.replaceAll("o", "1").replaceAll("x", "0"); int max = 0; for (int i = 0; i < (1 << 14); i++) { if (Integer.bitCount(i & Integer.parseInt(string, 2)) != Integer.bitCount(Integer.parseInt(string, 2))) { continue; } if (Integer.bitCount(i) > Integer.bitCount(Integer.parseInt(string, 2)) + D) { continue; } char[] bits = ("0" + Integer.toBinaryString(i) + "0").toCharArray(); int cnt = 0; for (int j = 0; j < bits.length; j++) { if (bits[j] == '1') { cnt++; } else { max = Math.max(max, cnt); cnt = 0; } } } System.out.println(max); } }