#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int n, q;   char s[N];   struct node {     int s, x, z, xz, zy, d;   } tr[N << 2];   void upd(int o) {     int S = tr[(o << 1)].s, lx = tr[(o << 1)].x, lz = tr[(o << 1)].z,         lxz = tr[(o << 1)].xz, lzy = tr[(o << 1)].zy;     int rx = tr[(o << 1 | 1)].x + S, rz = tr[(o << 1 | 1)].z - 2 * S,         rxz = tr[(o << 1 | 1)].xz - S, rzy = tr[(o << 1 | 1)].zy - S;     tr[o].s = S + tr[(o << 1 | 1)].s;     tr[o].x = max(lx, rx), tr[o].z = max(lz, rz);     tr[o].xz = max(max(lxz, rxz), lx + rz);     tr[o].zy = max(max(lzy, rzy), lz + rx);     tr[o].d =         max(max(tr[(o << 1)].d, tr[(o << 1 | 1)].d), max(lxz + rx, lx + rzy));   }   void mdf(int o, int l, int r, int p, int c) {     if (l == r) {       tr[o] = {c, c, -2 * c, -c, -c, 0};       return;     }     int mid = (l + r) >> 1;     if (p <= mid)       mdf((o << 1), l, mid, p, c);     else       mdf((o << 1 | 1), mid + 1, r, p, c);     upd(o);   }   int main() {     scanf( %d%d%s , &n, &q, s + 1);     for (int i = (1); i <= (2 * n - 2); ++i)       mdf(1, 1, 2 * n - 2, i, s[i] ==  (  ? 1 : -1);     printf( %d n , tr[1].d);     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       swap(s[x], s[y]);       mdf(1, 1, 2 * n - 2, x, s[x] ==  (  ? 1 : -1);       mdf(1, 1, 2 * n - 2, y, s[y] ==  (  ? 1 : -1);       printf( %d n , tr[1].d);     }     return 0;   }   