// Arup Guha
// 12/19/2019
// Solution to 2019 December USACO Bronze Problem: Where Am I?

import java.util.*;
import java.io.*;

public class whereami {

	public static void main(String[] args) throws Exception {
		
		// Read in the basic graph parameters.
		Scanner stdin = new Scanner(new File("whereami.in"));
		int n = stdin.nextInt();
		String s = stdin.next();
		
		int res = -1;
		
		// Try each length.
		for (int i=1; i<=n; i++) {
		
			// Store all substrings of length i here.
			boolean ok = true;
			HashSet<String> set = new HashSet<String>();
			
			// j is the starting point.
			for (int j=0; j<n-i+1; j++) {
			
				String tmp = s.substring(j, j+i);
			
				// Oops we've seen this one before.
				if (set.contains(tmp)) {
					ok = false;
					break;
				}
				
				// Add this string to our set.
				set.add(tmp);
			}
			
			// Found something that works!
			if (ok) {
				res = i;
				break;
			}
		}

		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("whereami.out"));
		out.println(res);
		out.close();		
		stdin.close();
	}
}