#include<iostream>
#include<string>
#include<vector>
using namespace std;

#define count_bits(bits) \
    (((bits & 0x0001) == 0x0001) + \
    ((bits & 0x0002) == 0x0002) + \
    ((bits & 0x0004) == 0x0004) + \
    ((bits & 0x0008) == 0x0008) + \
    ((bits & 0x000f) == 0x000f) + \
    ((bits & 0x0010) == 0x0010) + \
    ((bits & 0x0020) == 0x0020) + \
    ((bits & 0x0040) == 0x0040) + \
    ((bits & 0x0080) == 0x0080) + \
    ((bits & 0x00f0) == 0x00f0) + \
    ((bits & 0x0100) == 0x0100) + \
    ((bits & 0x0200) == 0x0200) + \
    ((bits & 0x0400) == 0x0400) + \
    ((bits & 0x0800) == 0x0800) + \
    ((bits & 0x0f00) == 0x0f00) + \
    ((bits & 0x1000) == 0x1000) + \
    ((bits & 0x2000) == 0x2000) + \
    ((bits & 0x4000) == 0x4000) + \
    ((bits & 0x8000) == 0x8000) + \
    ((bits & 0xf000) == 0xf000))

int main() {
    int n;
    cin >> n;
    vector<uint32_t> amounts(n+1);
    amounts[0] = 0;

    string days;
    cin >> days;

   

    uint32_t cur = 0;
    for(uint32_t i = 0; i < n; i++){
        cur ^= (1 << (days[i]-'a'));
        amounts[i+1] = cur;
    }

    if (count_bits(cur) <= 1) {
        cout << n << endl;
        return 0;
    }

    for (uint32_t len = n-1; len >= 0; len--) {
        for (uint32_t offset = 0; offset < (n - len); offset++) {
            if (count_bits(amounts[len+offset] ^ amounts[offset]) <= 1) {
                cout << len << endl;
                return 0;
            }
        }
    }

    return 1;
}

