1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<cstdio>
#include<algorithm>
#define FOR(i,n) for(int i = 0; i < (n); i++)

char s[200005];

int blue = 0;
int n, q;

void count(){
    FOR(i, n) {
        if (s[i] == 'N') {
            blue++;
        }
    }
}

void replace(int k, char c) {
    if (s[k] == 'N') {
        blue--;
    }
    if (c == 'N') {
        blue++;
    }
    s[k] = c;
}

int main() {
    scanf("%d%d%s", &n, &q, s);
    count();
    printf("%d\n", std::max(2*blue - 1, 0));
    while (q--) {
        int k;
        char c;
        scanf("%d %c", &k, &c);
        replace(k - 1, c);
        printf("%d\n", std::max(2*blue - 1, 0));
    }
    return 0;
}