import java.io.*; import java.util.*; public class broken { public static boolean in (char[] arr, char c) { for (char x: arr) if (x == c) return true; return false; } public static void main (String... args) throws Exception { BufferedReader reader = new BufferedReader(new FileReader("broken.in")); int n = Integer.parseInt(reader.readLine()); while (n > 0) { String in = reader.readLine(); char[] c = in.toCharArray(); int max = 0; for (int i = 0; i < c.length; i++) { int tmp = 0; int used_keys = 0; char[] keys = new char[n]; for (int j = i; j < c.length; j++) { if (in(keys, c[j])) { tmp++; } else { if (used_keys < n) { keys[used_keys] = c[j]; used_keys++; tmp++; } else { break; } } } max = (max > tmp) ? max : tmp; } System.out.println(max); n = Integer.parseInt(reader.readLine()); } } }