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.util.*;

    public class TwoGram {
        
        public static void main(String[] args) {
            
            Scanner scan = new Scanner(System.in);
            
            int n = scan.nextInt();
            
            String s = scan.next();
            String[] arr = new String[n-1];
            for(int i=1; i<s.length(); i++) {
                arr[i-1] = s.substring(i-1,i+1);
                
            }
            
            int counter = 1;
            
            int max = 1;
            
            String champ = "";
            
            Arrays.sort(arr);
            
            for(int j=1; j<arr.length; j++) {
                if(arr[j].equals(arr[j-1])) {
                    counter ++;
                }    
                else {
                    if(counter > max) {
                        max = Math.max(max,counter);
                        champ = arr[j-1];
                        counter = 1;
                    }else{
                        counter = 1;
                    }
                }
               
            }
            if(max == 1) {
                    System.out.println(arr[0]);
                }
            
            System.out.println(max);
            System.out.println(counter);
            System.out.println(champ);
            System.out.println(Arrays.toString(arr));
            
            
            
        }
    } 