package bill;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Mugs {

    public static void main(String[] args) {
	// write your code here

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        int textLength = 0;
        String text = "";
        try {
            textLength = Integer.parseInt(bufferedReader.readLine());
            text = bufferedReader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

//      calculate OPT(i). Its value is maximum length of palindrome found in str(0, i)
        int maxPalindromeLength = 0;
        String substr = "";
        for (int i = 1; i <= textLength; i++)
        {
            substr = text.substring(0, i);
            int palindromeLengthWithLastCharIncluded = getMaxPalindromeLengthWithLastCharIncluded(substr);
            if (maxPalindromeLength < palindromeLengthWithLastCharIncluded)
            {
                maxPalindromeLength = palindromeLengthWithLastCharIncluded;
            }
        }
        System.out.println(maxPalindromeLength);
    }

    private static int getMaxPalindromeLengthWithLastCharIncluded(String text) {
        int max = 0;
        for(int i = text.length() - 1; i >= 0; i--)
        {
            String charsIncluded = text.substring(i, text.length());
            if(testIfPalindrome(text.substring(i, text.length()))) {
                 max = charsIncluded.length();
             }
        }
        return max;
    }

    private static boolean testIfPalindrome(String substr) {

        Map<String, Integer> letterOccurences = new HashMap<>();
        for(int i = 0; i < substr.length(); i++)
        {
            String key = substr.charAt(i) + "";
            if(letterOccurences.containsKey(key))
            {
                letterOccurences.put(key + "", letterOccurences.get(key) + 1);
            } else {
                letterOccurences.put(key + "", 1);
            }
        }

        int sum = 0;
        for(Map.Entry<String, Integer> entry : letterOccurences.entrySet())
        {
            sum += entry.getValue() % 2;
        }
        return (substr.length() % 2 == 0 && sum == 0) || (substr.length() % 2 == 1 && sum == 1) ;
    }
}

