#include using namespace std; const int N = 4e5+5; const long long A = 1e9+7; const long long B = 1e9+9; #define ll long long int n; string s; long long p[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); p[0] = 1; for (int i = 1; i < N; ++i) { p[i] = (p[i-1]*A)%B; } cin >> n >> s; string q(s.rbegin(), s.rend()); long long h = 0; set sh; for (int i = 0; i < n; ++i) { h = (h + ((ll)(q[i]-'a'+1)*p[i])%B)%B; //cout << h << ' ' << q[i] << endl; sh.insert(h); } //cout << endl; h = 0; int ans = 0; for (int i = 0; i < n; ++i) { h = ((h*A)%B + (ll)(q[i]-'a'+1))%B; //cout << h << ' ' << q[i] << endl; if (sh.count(h)) { ans = max(ans, i); } } ans = n-ans-1; cout << ans; return 0; }