#include #define st first #define nd second #define fi first #define se second #define pb push_back #define ps(v) cout << v << " " #define pln(v) cout << v << "\n" #define entr cout << "\n" using namespace std; typedef long long ll; typedef long double ld; typedef pair pll; int main() { ios_base::sync_with_stdio(0); int n; string a; cin >> n >> a; string c; for (int i = 0; i < n; i++) { c.push_back(a[i]); c.push_back('#'); } c.push_back('$'); int s = c.size(); vector P(s); for (int i = 0, k = 0; i < s; i++) { if (k+P[k] > i) { P[i] = max(1, min(P[2*k-i], k+P[k]-i)); } while (P[i] <= i && c[i+P[i]] == c[i-P[i]]) { P[i]++; } if (i+P[i] > k+P[k]) { k = i; } //cout << P[i] << " "; } //cout <= s-2) { ans = min(ans, (i-P[i]+2) / 2); } } else { //cout << i << " " << c[i] << " " << i+P[i] << " " << (i-P[i]+2)/2 <= s-1) { ans = min(ans, (i-P[i] + 2) / 2); } } //cout << ans <