import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Mugs { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int chars = Integer.parseInt(br.readLine()); List charPoints = new ArrayList<>(); int bestLenght = 1; for (int i = 0; i < chars; i++){ char c = (char)br.read(); for (MatrixPoint mp:charPoints) { mp.insert(c); if(mp.checkValid()){ if(mp.length > bestLenght){ bestLenght = mp.length; } } } MatrixPoint temp = new MatrixPoint(); temp.insert(c); charPoints.add(temp); } System.out.println(bestLenght); } } class MatrixPoint{ public int[] charOccur = new int[20]; int length = 0; public void insert(char c){ charOccur[c - 'a']++; length++; } public boolean checkValid(){ int odd = 0; for (int i = 0; i < charOccur.length; i++) { odd += charOccur[i] % 2 == 1 ? 1 : 0; } return odd <= 1; } }