#include #define FOR(a, b, c) for(int a = b; a < c; ++a) #define MP make_pair #define PB push_back #define SIZE(a) (int)a.size() using namespace std; typedef long long LL; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string s; cin >> n >> s; map M; int res = 0; vector ile(20); M[0] = -1; FOR(i, 0, n) { ile[s[i] - 'a']++; int mask = 0; FOR(j, 0, 20) { // cerr << ile[j] << " "; if(ile[j] % 2 == 1) { mask += (1 << j); } } // cerr << "\n"; // cerr << mask << "\n"; if(M.count(mask)) { // cerr << i - M[mask] + 1 << "\n"; res = max(res, i - M[mask]); } FOR(j, 0, 20) { mask ^= (1 << j); if(M.count(mask)) { // cerr << bitset<20>(mask) << " : " << i - M[mask] + 1 << "\n"; res = max(res, i - M[mask]); } mask ^= (1 << j); } if(not M.count(mask)) { M[mask] = i; } } cout << res << "\n"; return 0; }