#include <bits/stdc++.h>

using namespace std;

int solve(const string& s) {
    if (s.length() == 0) return 0;
    if (s.length() == 1) return 1;

    if (s.front() == s.back()) {
        return 2 + solve(s.substr(1, s.length() - 2));
    } else {
        return max(solve(s.substr(1)), solve(s.substr(0, s.length() - 1)));
    }
}

int main() {
    int n; cin >> n;
    string s; cin >> s;

    cout << solve(s) << endl;

    return 0;
}