#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





vector<int> manacher(string s) {
    vector<int> r(s.size());
    int c = 0;
    for (int i = 0; i < s.size(); ++i) {
        int l = c - (i - c);
        // cout << r[l] << endl;
        if (i + r[l] < c + r[c]) r[i] = r[l];
        else {
            int j = c + r[c] - i;
            while (i - j >= 0 && i + j < s.size() && s[i - j] == s[i + j]) ++j;
            r[i] = j;
            c = i;
        }
    }
    // rep(i, sz(s)) cout << r[i] << " "; cout << endl;
    return r;
    /*
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        ans = max(ans, r[i]);
    }
    return ans;
     */
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    // 長さ2以上
    
    vector<int> r = manacher(s);
    rep3(len, 2, sz(s) + 1) {
        int flg = 0;
        rep3(k, 1, 2000000) {
            int i = (len - 1) * k;
            if (i >= sz(s)) break;
            if (r[i] != min(i + 1, n - i)) {
                flg = 1;
                break;
            }
        }
        if (flg == 0) {
            cout << len << endl;
            return 0;
        }
    }
}

