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
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
n, q = map(int, input().split())
start = list(input())
# print(n, q)
# print(start)

def czekamy72(start):
  # print("\n czekamy72", start)
  tab = []
  tab.append(start)

  out = []
  while len(tab) > 0:
    act = tab.pop(0)
    # print("act:", act)
    jest = False
    for i in range(len(act)):
      if act[i] == "N":
        jest = True
        tmp = act.copy()
        tmp[i] = "Z"
        tab.append(tmp)
        tmp = act.copy()
        tmp[i] = "C"
        tab.append(tmp)
        # print("E:", tab)
        break
    if not jest:
      #print(act)
      out.append(act)
  return out

def reakcje(atomy):
  # print("reakcje", atomy)
  tab = [{"j": 0, "a": atomy}]
  while len(tab) > 0:
    aj = tab.pop(0)
    atomy = aj["a"]
    dzule = aj["j"]
    for i in range(len(atomy) - 1):
      if atomy[i] == atomy[i + 1]:
        atomy2 = atomy.copy()
        if atomy2[i] == "C":
          atomy2[i + 1] = "Z"
        else:
          atomy2[i + 1] = "C"
        del atomy2[i]
        #print("---dzule:", dzule + 1, "n:", n - 1, "a:", len(atomy2))
        if dzule + 1 == n - 1:
          if len(atomy2) == 1:
          # print("znalazłem!")
            return True
        else:
          tab.append({"j": dzule + 1, "a": atomy2})

    # print("tab", tab)
  # print("NIE znalazłem!")
  return False


def caly_proces(start):
  out = czekamy72(start)
  # print(out)

  wynik = 0
  for i in range(len(out)):
    if reakcje(out[i]):
      wynik += 1
    # break
  return wynik

wynik = caly_proces(start)
print(wynik)
# print("start", start)

for i in range(q):
  k, ch = input().split()
  k = int(k)
  # print(k, ch)
  start[k - 1] = ch
  # print(start)
  wynik = caly_proces(start)
  print(wynik)


# def zamiana_n(str):
#   jest = False
#   for i in range(len(str)):
#     if str[i] == 'N':
#       jest = True
#       str2 = str.copy()
#       str2[i] = 'C'
#       #print("w1:", str2)
#       zamiana_n(str2)
#       str2 = str.copy()
#       str2[i] = 'Z'
#       #print("w2:", str2)
#       zamiana_n(str2)
#       return
#   if not jest:
#     print(str)
#     # tab.append(str)

# zamiana_n(start)
# print(tab)