#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

ll __pow(ll a, ll b, ll mod) { return b ? (b & 1 ? a : 1) * __pow(a * a % mod, b / 2, mod) % mod : 1; }

struct RollingHash {
    const V<ll> &bases;
    const V<ll> &mods;
    VV<ll> pows;
    VV<ll> hashs;
    RollingHash(const string &s, const V<ll> &bases, const V<ll> &mods, ll l, ll r) 
        : bases(bases), mods(mods) 
    {
        for(ll i = 0; i < mods.size(); i++) {
            ll mod = mods[i];
            ll base = bases[i];
            V<ll> hash(s.size() + 1, 0);
            V<ll> _pow(s.size() + 1, 1);
            for(ll j = l; j < r; j++) {
                hash[j + 1] = (hash[j] + (s[j] - 'a')) * base % mod;
                _pow[j + 1] = _pow[j] * base % mod;
            }
            hashs.push_back(move(hash));
            pows.push_back(move(_pow));
        }
    }

    // [l, r]
    V<ll> get_hash(ll l, ll r) {
        V<ll> ret;
        for(ll i = 0; i < mods.size(); i++) {
#if 1
            ll h = hashs[i][r] - hashs[i][l] * pows[i][r - l] % mods[i];
            h += mods[i];
            h %= mods[i];
#else
            ll h = hashs[i][r] - hashs[i][l];
            (h += mods[i]) %= mods[i];
            h *= __pow(bases[i], l, mods[i] - 2);
            h %= mods[i];
#endif
            ret.push_back(h);
        }
        return move(ret);
    }
};

int main() {
    ll N;
    string S;
    string RS;
    cin >> N >> S;
    V<ll> mods = {
        //998244353,
        //(ll)1e9 + 7,
        998244353,
    };
    V<ll> bases = {
        //997,
        //1007,
        9973,
    };
    if(N <= 1e5) {
        mods.push_back((ll)1e9  + 9);
        mods.push_back((ll)1e9 + 7);
        mods.push_back(74317);
        bases.push_back(1007);
        bases.push_back(1009);
        bases.push_back(997);
    }
    RS = S;
    reverse(ALL(RS));
    /*
    {
        auto cpy = S;
        sort(ALL(cpy));
        auto ite = unique(ALL(cpy));
        cpy.erase(ite, cpy.end());
        if(cpy.size() == 1) {
            cout << 1 << endl;
            return 0;
        }
    }
    */
    auto rolls = RollingHash(S, bases, mods, 0, S.size());
    auto rollrs = RollingHash(RS, bases, mods, 0, S.size());
    DEBUG(rolls.get_hash(0, 2));
    DEBUG(rolls.get_hash(4, 6));
    for(ll i = 2; i <= S.size(); i++) {
        V<ll> hs = rolls.get_hash(0, i);
        V<ll> hrs = rollrs.get_hash(S.size() - i, S.size());
        bool even = true;
        bool suc = true;
        DEBUG(i);
        for(ll j = 0; j < S.size() - 1; j += i - 1) {
            ll len = min<ll>(i, S.size() - j);
            V<ll> h1;
            if(len == i) {
                h1 = (even ? hs : hrs);
            } else {
                if(even) h1 = rolls.get_hash(0, len);
                else h1 = rollrs.get_hash(S.size() - i, S.size() - i + len);
            }
            V<ll> h2 = rolls.get_hash(j, j + len);
            DEBUG(j);
            DEBUG(len);
            DEBUG(h1);
            DEBUG(h2);
            DEBUG(even);
            DEBUG(S.substr(j, len));
            for(ll k = 0; k < h1.size(); k++) if(h1[k] != h2[k]) suc = false;
            if(!suc) break;
            even = !even;
        }
        DEBUG_SEPARATOR_LINE;
        if(suc) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 36192