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

#define count_bits(bits) \
   (((bits & 0x00000001) == 0x00000001) + \
    ((bits & 0x00000002) == 0x00000002) + \
    ((bits & 0x00000004) == 0x00000004) + \
    ((bits & 0x00000008) == 0x00000008) + \
    ((bits & 0x00000010) == 0x00000010) + \
    ((bits & 0x00000020) == 0x00000020) + \
    ((bits & 0x00000040) == 0x00000040) + \
    ((bits & 0x00000080) == 0x00000080) + \
    ((bits & 0x00000100) == 0x00000100) + \
    ((bits & 0x00000200) == 0x00000200) + \
    ((bits & 0x00000400) == 0x00000400) + \
    ((bits & 0x00000800) == 0x00000800) + \
    ((bits & 0x00001000) == 0x00001000) + \
    ((bits & 0x00002000) == 0x00002000) + \
    ((bits & 0x00004000) == 0x00004000) + \
    ((bits & 0x00008000) == 0x00008000) + \
    ((bits & 0x00010000) == 0x00010000) + \
    ((bits & 0x00020000) == 0x00020000) + \
    ((bits & 0x00040000) == 0x00040000) + \
    ((bits & 0x00080000) == 0x00080000) + \
    ((bits & 0x00100000) == 0x00100000) + \
    ((bits & 0x00200000) == 0x00200000) + \
    ((bits & 0x00400000) == 0x00400000) + \
    ((bits & 0x00800000) == 0x00800000) + \
    ((bits & 0x01000000) == 0x01000000) + \
    ((bits & 0x02000000) == 0x02000000) + \
    ((bits & 0x04000000) == 0x04000000) + \
    ((bits & 0x08000000) == 0x08000000) + \
    ((bits & 0x10000000) == 0x10000000) + \
    ((bits & 0x20000000) == 0x20000000) + \
    ((bits & 0x40000000) == 0x40000000) + \
    ((bits & 0x80000000) == 0x80000000))

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;
}

