#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


namespace str{
    vector<ll> Manacher(const string &s){
        vector<ll> ret(s.size(),0);
        int j=0;
        for(int i=0;i<s.size();){
            while(i>=j && i+j<s.size() && s[i-j]==s[i+j]){j++;}
            ret[i]=j;
            int k=1;
            while(k<j && ret[i-k]+k<j){ret[i+k]=ret[i-k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    vector<ll> Z_Algorithm(const string &s){
        vector<ll> ret(s.size(),0);
        ret[0]=s.size();
        int j=0;
        for(int i=1;i<s.size();){
            while(i+j<s.size() && s[j]==s[i+j]){j++;}
            ret[i]=j;
            if(j==0){i++; continue;}
            int k=1;
            while(k+ret[k]<j){ret[i+k]=ret[k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    //1-indexed
    vector<ll> MP(const string &s){
        vector<ll> ret(s.size()+1,-1);
        ll j=-1;
        for(int i=0;i<s.size();i++){
            while(j>=0 && s[i]!=s[j]){j=ret[j];}
            j++;
            ret[i+1]=j;
        }
        return ret;
    }
};


using namespace str;



int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> A=Manacher(s);
    vector<ll> B=Z_Algorithm(s);
    ll ans=E;
    if(B[1]+1==n){cout<<2<<endl; return 0;}
    for(ll i=3;i<2*n;i+=2){
        if(i<n && B[i-1]+i-1==n && A[i/2]==min((i+1)/2,n-(i/2))){ans=min(ans,i);}
        if(i>=n && A[i/2]==min((i+1)/2,n-(i/2))){ans=min(ans,i);}
    }
    cout<<min((ans+1)/2,n)<<endl;
    
    
    
    return 0;
}

