// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

template<class ForwardIterator>
vector<ll> Z_algorithm(ForwardIterator first, ForwardIterator last) {
  const ll n = last - first;
  vector<ll> Z(n, 0);
  ll left = 0;
  rep(i, 1, n) {
    ll right = left + Z[left];
    if (i < right && Z[i - left] < right - i) {
      Z[i] = Z[i - left];
    }
    else {
      left = i;
      chmax(right, left);
      while (right < n && *(first + right - i) == *(first + right)) {
        ++right;
      }
      Z[i] = right - i;
    }
  }
  Z[0] = n;
  return Z;
}

template<typename String>
vector<ll> manachar(const String& s) {
  vector<ll> res(s.size());
  ll i = 0, j = 0;
  while (i < s.size()) {
    while (i-j >= 0 && i+j < s.size() && s[i-j] == s[i+j]) ++j;
    res[i] = j;
    ll k = 1;
    while (i-k >= 0 && i+k < s.size() && k+res[i-k] < j) res[i+k] = res[i-k], ++k;
    i += k; j -= k;
  }
  return res;
}

void solve() {
  ll n; cin >> n;
  string s; cin >> s;
  n = s.size();
  vector<ll> Z = Z_algorithm(all(s));
  // if (*min_element(all(Z)) >= 1) {
  //   cout << 1 << endl;
  //   return;
  // }
  vector<ll> R = manachar(s);
  // cout << R << endl;
  for (ll len = 2; (len+2)/2 <= n; len += 2) {
    bool is_ok = true;
    for (ll j = 0; j < n; j += len) {
      if (Z[j] < min(len, n-j)) {
        is_ok = false;
        break;
      }
    }
    if (!is_ok) continue;
    ll center = len/2;
    ll left = center-R[center]+1, right = center+R[center];
    // cout << len << " " << left << " " << right << endl;
    if (left == 0 || right == n || right-left >= len+1) {
      cout << (len+2)/2 << endl;
      return;
    }
  }
}



Measured memory_bytes: 19832