#region ZIPPER using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using sc = Scanner; using ci = CharInterpreter; //using System.Numerics; //using Geometry; //using gl = Geometry.GeometryLibrary; //using grl = GraphLibrary; class Program { static void Main(string[] args) { Solver solver = new Solver(); solver.Solve(); #if DEBUG System.Console.WriteLine("続行するには何かキーを押してください..."); System.Console.ReadKey(); #endif } } /// /// 標準入力読み取り支援,自作(某最速の人を参考) /// #endregion ZIPPER public class Solver { #region IGNORE_ME public Solver() { //こんすとらくたん きにしなくてよろしい } #endregion IGNORE_ME public int MOD = 1000000007;//10^9 + 7 public void Solve() { int k = sc.NextInt(); string m = Console.ReadLine() + Console.ReadLine(); List list = new List(); bool sagasi_maru = true; int ans = 0; int tmpM = 0; int tmpB = 0; for (int i = 0; i < m.Length; i++) { if (m[i] == 'o') { if (sagasi_maru) { tmpM++; } else { list.Add(new int[] { -1, tmpB }); sagasi_maru = true; tmpM = 1; tmpB = 0; } } else // x { if (!sagasi_maru) { tmpB++; } else { list.Add(new int[] { 1, tmpM }); sagasi_maru = false; tmpM = 0; tmpB = 1; } } } if (tmpB != 0) { list.Add(new int[] { -1, tmpB }); } else { list.Add(new int[] { 1, tmpM }); } for (int i = 1; i < list.Count-1; i++) { if (list[i][0] == -1 && list[i][1] <= k) { ans = Math.Max(ans,list[i-1][1] + list[i][1] + list[i+1][1]); } } for (int i = 0; i < list.Count; i++) { if (list[i][0] == 1) { ans = Math.Max(ans, list[i][1]); } } if (list.Count > 2 && list[0][0] == -1) { ans = Math.Max(ans, Math.Min(list[0][1], k) + list[1][1]); } if (list.Count > 2 && list[list.Count-1][0] == -1 && list[list.Count-1][1] <= k) { ans = Math.Max(ans, list[list.Count - 2][1] + Math.Min(k, list[list.Count - 1][1])); } ans = Math.Max(ans, k); Console.WriteLine(ans); #if DEBUG Console.WriteLine("t");//local check #endif } } #region STANDARD_READER public static class Scanner { public static string NextString() { string tmp = ""; while (true) { int readData; string data; readData = Console.Read(); if (readData == -1) //EOF { break; } data = char.ConvertFromUtf32(readData); if (data == " " || data == "\n") { break; } tmp += data; } return tmp; } public static int NextInt() { string tmp = ""; while (true) { int readData; string data; readData = Console.Read(); if (readData == -1) //EOF { break; } data = char.ConvertFromUtf32(readData); if (data == " " || data == "\n") { break; } tmp += data; } return int.Parse(tmp); } public static long NextLong() { string tmp = ""; while (true) { int readData; string data; readData = Console.Read(); if (readData == -1) //EOF { break; } data = char.ConvertFromUtf32(readData); if (data == " " || data == "\n") { break; } tmp += data; } return long.Parse(tmp); } public static double NextDouble() { string tmp = ""; while (true) { int readData; string data; readData = Console.Read(); if (readData == -1) //EOF { break; } data = char.ConvertFromUtf32(readData); if (data == " " || data == "\n") { break; } tmp += data; } return double.Parse(tmp); } public static string[] NextStrArray() { return Console.ReadLine().Split(' '); } public static int[] NextIntArray() { string[] s = NextStrArray(); int[] a = new int[s.Length]; for (int i = 0; i < a.Length; i++) { a[i] = int.Parse(s[i]); } return a; } public static long[] NextLongArray() { string[] s = NextStrArray(); long[] a = new long[s.Length]; for (int i = 0; i < a.Length; i++) { a[i] = long.Parse(s[i]); } return a; } public static double[] NextDoubleArray() { string[] s = NextStrArray(); double[] a = new double[s.Length]; for (int i = 0; i < a.Length; i++) { a[i] = double.Parse(s[i]); } return a; } } /// /// 二次元グリッドなどの文字列で与えられたマップなどで、 /// 手軽にデータ変換を適用するためのクラス /// public static class CharInterpreter { /// /// 変換用辞書 /// private static Dictionary MapToInt = new Dictionary(); /// /// 変換法則を追加する /// /// char文字 /// 対応する整数値 public static void AddCorrespondence(char c,int i) { MapToInt.Add(c,i); } /// /// 文字列に対して、対応付けされた /// 例外処理をしていないので注意 /// /// 対応対応がなかった場合はバグる;; public static int Inquiry(char c) { int ret = 0; MapToInt.TryGetValue(c, out ret); return ret; } /// /// 指定された変換法則の元でint[,]の二次元平面を生成する /// 対応関係がない場合の例外処理をしていないので注意 /// /// 配列の各文字列の長さが全て同じでないとうまく作動しないので注意 /// int[ field.length , field[0].length]型の配列 public static int[,] GenerateSquareField(string[] field) { int[,] ret = new int[field.Length, field[0].Length]; for (int i = 0; i < field.Length; i++) { for (int j = 0; j < field[0].Length; j++) { MapToInt.TryGetValue(field[i][j], out ret[i, j]); } } return ret; } } #endregion STANDARD_READER