// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[200010],vis(200010,0),dis(200010,inf),fin(200010,0),col(200010,0),par(200010,0);
int myrandom (int i) { return std::rand()%i;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    string str;
    cin>>str;
    int dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    int res_length  = 0;
    int i, index = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (str[i-1]==str[j-1]&&dp[i-1][j-1]<(j - i))
            {
                dp[i][j]=dp[i-1][j-1]+1;
                if(dp[i][j]>res_length)
                {
                    res_length=dp[i][j];
                    index=max(i,index);
                }
            }
            else
            {
                dp[i][j] = 0;
            }
        }
    }
    int cnt=0;
    if(res_length>0)
    {
        for (i = index - res_length + 1; i <= index; i++)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}
// 11906472
// YHUHA8ZBJH
// Preeyadarshee Dev Team 808db2e1
/*
 int a1,a2,k1,k2,n;
 cin>>a1>>a2>>k1>>k2>>n;
 int num=(k1-1)*a1+(k2-1)*a2;
 if(n-num<=0)
 {
 cout<<0<<" ";
 }
 else
 {
 cout<<min(n-num,a1+a2)<<" ";
 }
 int maxi=0;
 for(int i=1;i<=n;i++)
 {
 int j=n-i;
 maxi=max(maxi,min((i/k1),a1)+min((j/k2),a2));
 }
 cout<<maxi<<endl;
 */
/*
 int n;
 cin>>n;
 string s,t;
 cin>>s>>t;
 deque<int> v[2];
 vector<int> cnt(2,0);
 for(int i=0;i<n;i++)
 {
 if(s[i]=='a'&&t[i]=='b')
 {
 cnt[0]++;
 v[0].pb(i);
 }
 else if(s[i]=='b'&&t[i]=='a')
 {
 cnt[1]++;
 v[1].pb(i);
 }
 }
 vector<pair<int,int>> ans;
 while((int)v[0].size()>1)
 {
 ans.pb({v[0].front()+1,v[0].back()+1});
 v[0].pop_front();
 v[0].pop_back();
 }
 while((int)v[1].size()>1)
 {
 ans.pb({v[1].front()+1,v[1].back()+1});
 v[1].pop_front();
 v[1].pop_back();
 }
 if(!v[0].empty()&&!v[1].empty())
 {
 ans.pb({v[0].front()+1,v[0].back()+1});
 ans.pb({v[0].front()+1,v[1].back()+1});
 
 }
 else if(!v[0].empty()||!v[1].empty())
 {
 cout<<-1<<endl;
 return 0;
 }
 cout<<(int)ans.size()<<endl;
 for(auto i:ans)
 {
 cout<<i.ff<<" "<<i.ss<<endl;
 }
 */


Measured memory_bytes: 106624