#include using namespace std; #define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define next uhfsdhfhsdufhsdsdhfhiosdhodf #define back rerererwrwerwerwerwewer typedef long long ll; int main() { fio int n; cin >> n; string s; cin >> s; string needle = s; reverse(needle.begin(),needle.end()); vector next(needle.size()+1,-1); for (ll i = 0; i < needle.size(); i++){ ll back = next[i]; while (back >= 0 && needle[back] != needle[i]) back = next[back]; next[i+1] = back+1; } vector res; ll pos = 0; for (ll i = 0; i < s.size(); i++){ while (pos >= 0 && needle[pos] != s[i]) pos = next[pos]; pos++; } cout << n-pos << '\n'; return 0; }