#include #include #include #include #define LL long long #define M 2005 #define P 1000 using namespace std; int n; string in; bool ispalin(const vector &histog) { int odd = 0; for (int i = 0; i < 26; ++i) { if (histog[i] % 2) odd++; } if (odd <= 1) return true; } bool palin(int k) { vector histog(26, 0); for (int i = 0; i < k; ++i) { histog[in[i] - 'a']++; } if (ispalin(histog)) return true; for (int i = k; i < n; ++i) { --histog[in[i - k] - 'a']; ++histog[in[i] - 'a']; if (ispalin(histog)) return true; } return false; } int main() { cin >> n >> in; for (int i = n; i > 0; --i) { if (palin(i)) { cout << i << endl; return 0; } } return 0; }