using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int yukyuCount = int.Parse(Reader.ReadLine()); StringBuilder sb = new StringBuilder(); sb.Append(Reader.ReadLine()); sb.Append(Reader.ReadLine()); this.input = this.SplitCalendar(sb.ToString()); List kumiawase = this.GetKumiawase(0, yukyuCount); int ans = 0; kumiawase.ForEach((a)=>{ string[] tmp = a.Split('x'); ans = Math.Max(ans, tmp.Max(b=>b.Length)); }); Console.WriteLine(ans); } private String[] SplitCalendar(string inpt) { List ans = new List(); int pos = 0; for(int i=1; i>> dic = new Dictionary>>(); private List GetKumiawase(int idx, int remainYukyu) { if(!dic.ContainsKey(idx)) { dic.Add(idx, new Dictionary>()); } if(dic[idx].ContainsKey(remainYukyu)) { return dic[idx][remainYukyu]; } List ans = new List(); if(idx == input.Length - 1) { if(remainYukyu == 0) { ans.Add(this.input[idx]); } else { if(input[idx].StartsWith("o")) { ans.Add(input[idx] + "o".PadLeft(remainYukyu, 'o')); } else { ans.Add("o".PadLeft(remainYukyu)); } } } else { if(this.input[idx].StartsWith("o")) { List tmp = this.GetKumiawase(idx+1, remainYukyu); tmp.ForEach(a=>ans.Add(this.input[idx] + a)); if(idx == 0 && remainYukyu > 0) { tmp = this.GetKumiawase(idx + 1, 0); tmp.ForEach(a=>ans.Add("o".PadLeft(remainYukyu, 'o') + this.input[idx] + a)); } } else { List tmp = this.GetKumiawase(idx+1, remainYukyu); tmp.ForEach(a=>ans.Add(this.input[idx] + a)); if(remainYukyu > 0) { if(remainYukyu >= this.input[idx].Length) { int len = this.input[idx].Length; if(idx == 0) { len = remainYukyu; } tmp = this.GetKumiawase(idx+1, 0); tmp.ForEach(a=>ans.Add("o".PadLeft(len, 'o') + a)); } else { string holiday = "o".PadLeft(remainYukyu, 'o'); string buisinessDay = "x".PadLeft(this.input[idx].Length - remainYukyu, 'x'); tmp = this.GetKumiawase(idx+1, 0); tmp.ForEach((a)=>{ ans.Add(holiday + buisinessDay + a); ans.Add(buisinessDay + holiday + a); }); } } } } this.dic[idx].Add(remainYukyu, ans); return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 14 ooxxxxx xxxxxxo "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }