import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; public class Main { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int days = Integer.parseInt(br.readLine()); String brands = br.readLine(); int max = 0; int currentCount = days; while(true) { int oddCount = 0; HashMap map = new HashMap<>(); int start = 0; /*for (int j = 0; j < currentCount; j++) { char x = brands.charAt(i+j); map.putIfAbsent(x, 0); int y = map.get(x); if (y%2==0){ oddCount++; } map.put(x, y+1); }*/ for (int i = 0; i < currentCount; i++) { char x = brands.charAt(i); map.putIfAbsent(x, 0); int y = map.get(x); if (y%2==0){ oddCount++; } else oddCount--; map.put(x, y+1); } if (oddCount<=1){ System.out.println(currentCount); System.exit(0); } else { for (int j = 1; j < days - currentCount; j++) { // mozna +1 char x = brands.charAt(j-1); if (map.get(x) % 2 == 0) { oddCount++; } else oddCount--; map.put(brands.charAt(j-1), map.get(x)-1); char y = brands.charAt(j+currentCount-1); map.putIfAbsent(y, 0); if (map.get(y)%2 ==0) { oddCount++; } else oddCount--; map.put(y, map.get(y)+1); if (oddCount<=1) { System.out.println(currentCount); System.exit(0); } } } currentCount--; } } }