#include #define st first #define nd second #define pb push_back #define rep(i, a, b) for(int i = (a); i < (b); ++i) #define sci(x) int x; cin >> x; #define scvi(v, n) vector v(n); rep(i, 0, n) cin >> v[i]; using namespace std; typedef long long ll; typedef pair ii; typedef vector vi; unordered_map occ; ll k(ll x) { return (x * x )% 10010101; } ll mpow(ll a, ll b) { return b == 0 ? 1ll : b & 1 ? (a * k(mpow(a, b>>1))) % 10010101 : k(mpow(a, b>>1)); } string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); sci(n); // string s; cin >> s; ll hash1 = 0; ll hash2 = 0; ll mod = 1000000007; ll p = 1; int max_lght = 1; for(int i = n - 1; i >= 0; --i) { hash1 = (hash1 + p * (s[i] - 'a' + 1)) % mod; hash2 = (31 * hash2 + (s[i] - 'a' + 1)) % mod; // cout << hash1 << ' ' << hash2 << '\n'; p = (p * 31) % mod; if(hash1 == hash2) { max_lght = n - i; } } cout << n - max_lght << '\n'; return 0; // string r = s; // reverse(r.begin(), r.end()); // if (n == 1) { // cout << 0 << '\n'; // return 0; // } // string rr = ""; // rep(i, 0, n / 2 + 1) { // rr += r[i]; // // cout << rr << '\n'; // occ[rr] = 1; // } // // cout << '\n'; // string s1 = s.substr(n - 1, 1); // string s2 = s.substr(n - 2, 1); // // cout << s1 << ' ' << s2 << '\n'; // // if(occ[ss] == 1) max_lght = i; // for(int i = 0; i <= n / 2; i++) { // // cout << s1 << '\n'; // if(occ[s1] == 1) max_lght = max(max_lght, 2 * i + 1); // if(n - 2 * i - 3 >= 0) // s1 = s[n - 2 * i - 3] + (s[n - 2 * i - 2] + s1.substr(0, s1.size() - 1)); // } // // cout << '\n'; // for(int i = 1; i <= n / 2; i++) { // // cout << s2 << '\n'; // if(occ[s2] == 1) max_lght = max(max_lght, 2 * i); // if(n - 2 * i - 2 >= 0) // s2 = s[n - 2 * i - 2] + (s[n - 2 * i - 1] + s2.substr(0, s2.size() - 1)); // } // cout << n - max_lght << '\n'; return 0; }