#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

template <class T>
vector<int> manacher(const vector<T>& s) {
  vector<int> R(s.size());
  int i = 0, j = 0;
  while (i < s.size()) {
    while (i-j >= 0 && i+j < s.size() && s[i-j] == s[i+j]) ++j;
    R[i] = j;
    int k = 1;
    while (i-k >= 0 && i+k < s.size() && k+R[i-k] < j) R[i+k] = R[i-k], ++k;
    i += k; j -= k;
  }
  return R;
}

struct Manacher {
  vector<int> a;
  template <class T> Manacher(const vector<T>& s, T DUMMY = -1) {
    int m = s.size() * 2 - 1;
    vector<T> t(m, DUMMY);
    for (int i = 0; i < s.size(); i++) {
      t[i * 2] = s[i];
    }
    a = manacher(t);
  }
  Manacher(const string& s, char DUMMY = '$') {
    int m = s.size() * 2 - 1;
    vector<char> t(m, DUMMY);
    for (int i = 0; i < s.size(); i++) {
      t[i * 2] = s[i];
    }
    a = manacher(t);
  }

  // [l, r)が回文かどうか
  bool is_palindrome(int l, int r) {
    return a[l + r - 1] >= r - l;
  }
};

signed main() {
  int n; cin >> n;
  string t; cin >> t;
  Manacher man(t);

  REPI (k, 2, n + 1) {
    bool ok = true;
    int l = 0, r = 2 * k - 1;
    while ((l + r) / 2 < n) {
      int dif = max(0LL, r - n);
      r -= dif, l += dif;
      ok &= man.is_palindrome(l, r);
      l += k - 1;
      r += k - 1;
    }
    if (ok) {
      cout << k << endl; return 0;
    }
  }
}



Measured memory_bytes: 21708