#include using namespace std; using ll = long long; using Vi = vector; using Pii = pair; #define mp make_pair #define pb push_back #define x first #define y second #define rep(i,b,e) for(int i = (b); i < (e); i++) #define each(a, x) for(auto& a : (x)) #define all(x) (x).begin(),(x).end() #define sz(x) int((x).size()) constexpr int ALPHA = 26; struct PalTree { Vi txt; Vi len{0, -1}; Vi link{1, 0}; vector> to{ {}, {} }; int last{0}; int ext(int i) { while (len[i]+2 > sz(txt) || txt[sz(txt)-len[i]-2] != txt.back()) i = link[i]; return i; } void add(int x) { txt.pb(x); last = ext(last); if (!to[last][x]) { len.pb(len[last]+2); link.pb(to[ext(link[last])][x]); to[last][x] = sz(to); to.emplace_back(); } last = to[last][x]; } }; int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(12); int n; cin >> n; string s; cin >> s; PalTree pal; each(c, s) { pal.add(c-'a'); } int maxSuf = pal.len[pal.last]; cout << n-maxSuf << endl; return 0; }