#include<iostream> #include<algorithm> #include<cstring> using namespace std ; const int N = 1e6 +10 ; char s[N] ; int n ; int ne[N] ; int main(){ cin >> n ; cin >> s + 1; int minn = 1e9 ; for(int i = 2 , j = 0; i <= n ;i ++){ while(j && s[i] != s[j+1]) j = ne[j] ; if(s[i] == s[j+1]){ minn = min(minn, i - j - 1 ) ; } ne[i] = j ; } cout << minn << endl ; return 0 ; }