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 KMP_String_Matching
{
	int KMPSearch(String pat, String txt)
	{
		int M = pat.length();
		int N = txt.length();

		// create lps[] that will hold the longest
		// prefix suffix values for pattern
		int lps[] = new int[M];
		int j = 0; // index for pat[]

		// Preprocess the pattern (calculate lps[]
		// array)
		computeLPSArray(pat,M,lps);

		int i = 0; // index for txt[]
		int res = 0; 
		int next_i = 0; 
		
		while (i < N)
		{
			if (pat.charAt(j) == txt.charAt(i))
			{
				j++;
				i++;
			}
			if (j == M)
			{
				// When we find pattern first time,
				// we iterate again to check if there 
				// exists more pattern
				j = lps[j-1];
				res++;

				// We start i to check for more than once
				// appearance of pattern, we will reset i 
				// to previous start+1
				if (lps[j]!=0)
					i = ++next_i;
				j = 0;
			}

			// mismatch after j matches
			else if (i < N && pat.charAt(j) != txt.charAt(i))
			{
				// Do not match lps[0..lps[j-1]] characters,
				// they will match anyway
				if (j != 0)
					j = lps[j-1];
				else
					i = i+1;
			}
		}
		return res;
	}

	void computeLPSArray(String pat, int M, int lps[])
	{
		// length of the previous longest prefix suffix
		int len = 0;
		int i = 1;
		lps[0] = 0; // lps[0] is always 0

		// the loop calculates lps[i] for i = 1 to M-1
		while (i < M)
		{
			if (pat.charAt(i) == pat.charAt(len))
			{
				len++;
				lps[i] = len;
				i++;
			}
			else // (pat[i] != pat[len])
			{
				// This is tricky. Consider the example.
				// AAACAAAA and i = 7. The idea is similar 
				// to search step.
				if (len != 0)
				{
					len = lps[len-1];

					// Also, note that we do not increment
					// i here
				}
				else // if (len == 0)
				{
					lps[i] = len;
					i++;
				}
			}
		}
	}

	// Driver program to test above function
	public static void main(String args[])
	{
	    Scanner scan=new Scanner(System.in);
	    int n=scan.nextInt();scan.nextLine();
		String txt = scan.nextLine();
		String pat="";
		int max=0;
		int ans;
		
		for( char i='A';i<='Z';i++ ){
		    for(char j='A';j<'Z';j++){
        		pat="";
        		pat+=i;
        		pat+=j;
        		//System.out.println(pat+" "+i+" "+j);
        		ans = new KMP_String_Matching().KMPSearch(pat,txt);
        	    if(max < ans) max=ans;
		    }
		}
	    
	    
	    
	    
	    
		System.out.println(max);
	}
}
