/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package mugs; import java.util.HashMap; import java.util.Scanner; /** * * @author boban3 */ public class Mugs { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNextLine()) { int pocetDni = sc.nextInt(); sc.nextLine(); String sekvencia = sc.nextLine(); skonci:for (int i = sekvencia.length(); i >= 0; i--) { pokracuj:for (int j = 0; j <= sekvencia.length() - i; j++) { String pom = sekvencia.substring(j, i + j); HashMap mapa = new HashMap<>(); for (int k = 0; k < pom.length(); k++) { char znak = pom.charAt(k); if (mapa.containsKey(znak)) { int pocet = mapa.get(znak) + 1; mapa.replace(znak, pocet); } else { mapa.put(pom.charAt(k), 1); } } boolean ibaRaz = false; for (Integer value : mapa.values()) { if (value % 2 != 0 && ibaRaz) continue pokracuj; if (value % 2 != 0 && !ibaRaz) { ibaRaz = true; } } System.out.println(pom.length()); break skonci; } } } } }