15
MIRZOYANOVECLOX
 23
AABBBAAACCCCCAAADDDDDDD
 2
QA
 11
GGRRAATTZZZ
 6
AZAZAZ
 10
SQSQSQSQTG
 3
KEK
 100
URXCAIZFIBNJTPCZHBQIBCILLPXZCFGMKKZMNPLCYGAVJVIBMCZEBSJWPSCPQDYCTTKPOKIJRSKIZPDGCHVOUTMPNECYORSFZFNC
 3
LOL
 2
WW
 8
PUTINVOR
 26
QWERTYUIOPASDFGHJKLZXCVBNM
 5
AZAZA
 9
EGORLETOV
 7
KADUROV
 9
MIKEPIDOR
 9
AAAAAAAAA
 100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 5
FUFEL
 50
NYQAHBYYOXLTRYQDMVENEMAQNBAKGLGQOLXNAIFNQTOCLNNQIA

MI
 DD
 QA
 ZZ
 AZ
 SQ
 KE
 IB
 LO
 WW
 PU
 QW
 AZ
 EG
 KA
 MI
 AA
 AA
 FU
 YQ

import java.io.*;
import java.math.*;
import java.util.*;
import static java.lang.Math.*;

public class SuperClassss{

    //ЗАПУСКАЕМ РЕШЕНИЕЕЕЕ
    static class Run{
        static void myMain(){
            int n = in.nextInt();
            ArrayList<Integer> cnt = new ArrayList<>((n+1)/2);
            String s = in.next();
            for(int i = 0; i+2<n; i+=2){
                String str = Character.toString(s.charAt(i))+Character.toString(s.charAt(i+1));
                cnt.add(prefix_function(str, s));
            }
            Collections.sort(cnt);
            print(cnt.get((n+1)/2-2));
        }
    }

    public static void main(String[] args) {
        Run.myMain();
        out.flush();
    }

    static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);
    static StreamTokenizer in1 = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static BufferedReader in2 = new BufferedReader(new InputStreamReader(System.in));

    static int prefix_function(String edit){
        int ans = 0;
        int len = edit.length(), pi[] = new int[len];
        for(int i = 1; i<len; i++){
            int j = pi[i-1];
            while(j>0 && edit.charAt(i)!=edit.charAt(j)) j = pi[j-1];
            if(edit.charAt(i)==edit.charAt(j)) j++;
            pi[i] = j;
            if(pi[i]==2) ans++;
        }
        return ans;
    }

    static int prefix_function(String s, String t){
        String edit = s+"#"+t;
        return prefix_function(edit);
    }

    //s - подстрока, t - текст
  /*  static int[] prefix_function(String s, String t){
        String edit = s+"#"+t;
        return prefix_function(edit);
    }

    static int[] prefix_function(String edit){
        int len = edit.length(), pi[] = new int[len];
        for(int i = 1; i<len; i++){
            int j = pi[i-1];
            while(j>0 && edit.charAt(i)!=edit.charAt(j)) j = pi[j-1];
            if(edit.charAt(i)==edit.charAt(j)) j++;
            pi[i] = j;
        }
        return pi;
    }*/


    public static <T> void print(T... args) {
        for (T x : args) {
            out.print(x.toString());
        }
    }

    public static <T> void println(T... args) {
        print(args);
        out.println();
    }

    public static long nextLong() {
        try {
            in1.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (long) in1.nval;
    }

    public static int nextInt() {
        try {
            in1.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (int) in1.nval;
    }

    static String nextLine(){
        return in.nextLine();
    }
    public static String nextString() {
        try {
            return in2.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static char nextChar() {
        try {
            return (char) in2.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return '!';
    }

    public static void readArray(int[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextInt();
    }

    public static void readArray(long[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextInt();
    }

    public static void readArray(char[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextChar();
    }

    public static void readArray(String[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = nextString();
    }

    public static void readArray(StringBuilder[] array) {
        for (int i = 0; i < array.length; i++)
            array[i] = new StringBuilder(nextString());
    }

    public static int gcd(int a, int b) {
        while (b != 0) {
            int tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }

    public static int lcm(int a, int b) {
        return a / gcd(a, b) * b;
    }

    public static int min(int...args){
        Arrays.sort(args);
        return (args[0]);
    }

    public static int max(int...args){
        Arrays.sort(args);
        return(args[args.length-1]);
    }

    static double s(int x1, int y1, int x2, int y2, int x3, int y3) {
        return Math.abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.0;
    }

    public static LinkedList<Integer> isPrimeList(int n) {
        LinkedList<Integer> res = new LinkedList<>();
        boolean prime[] = new boolean[n];
        Arrays.fill(prime, true);
        prime[1] = false;
        for (int i = 2; i * i < n; i++) {
            if (prime[i])
                for (int j = i * i; j < n; j += i)
                    prime[j] = false;
        }
        for (int i = 2; i < n; i++)
            if (prime[i]) res.add(i);
        return res;
    }

    public static BigInteger bigSqrt(BigInteger n) {
        BigInteger a = BigInteger.ONE.shiftLeft((n.bitLength() + 1) / 2), next = a.subtract(BigInteger.ONE);
        while (next.compareTo(a) < 0) {
            a = next;
            next = a.add(n.divide(a)).divide(BigInteger.valueOf(2));
        }
        return a;
    }
}