Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replacement as the following sequence of steps: find a substring ".." (two consecutive periods) in string s, of all occurrences of the substring let's choose the first one, and replace this substring with string ".". In other words, during the replacement operation, the first two consecutive periods are replaced by one. If string s contains no two consecutive periods, then nothing happens.

Let's define f(s) as the minimum number of operations of replacement to perform, so that the string does not have any two consecutive periods left.

You need to process m queries, the i-th results in that the character at position x_{i} (1 ≤ x_{i} ≤ n) of string s is assigned value c_{i}. After each operation you have to calculate and output the value of f(s).

Help Daniel to process all queries.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 300 000) the length of the string and the number of queries.

The second line contains string s, consisting of n lowercase English letters and period signs.

The following m lines contain the descriptions of queries. The i-th line contains integer x_{i} and c_{i} (1 ≤ x_{i} ≤ n, c_{i} — a lowercas English letter or a period sign), describing the query of assigning symbol c_{i} to position x_{i}.


-----Output-----

Print m numbers, one per line, the i-th of these numbers must be equal to the value of f(s) after performing the i-th assignment.


-----Examples-----
Input
10 3
.b..bz....
1 h
3 c
9 f

Output
4
3
1

Input
4 4
.cc.
2 .
3 .
2 a
1 a

Output
1
3
1
1



-----Note-----

Note to the first sample test (replaced periods are enclosed in square brackets).

The original string is ".b..bz....". after the first query f(hb..bz....) = 4    ("hb[..]bz...."  →  "hb.bz[..].."  →  "hb.bz[..]."  →  "hb.bz[..]"  →  "hb.bz.") after the second query f(hbс.bz....) = 3    ("hbс.bz[..].."  →  "hbс.bz[..]."  →  "hbс.bz[..]"  →  "hbс.bz.") after the third query f(hbс.bz..f.) = 1    ("hbс.bz[..]f."  →  "hbс.bz.f.")

Note to the second sample test.

The original string is ".cc.". after the first query: f(..c.) = 1    ("[..]c."  →  ".c.") after the second query: f(....) = 3    ("[..].."  →  "[..]."  →  "[..]"  →  ".") after the third query: f(.a..) = 1    (".a[..]"  →  ".a.") after the fourth query: f(aa..) = 1    ("aa[..]"  →  "aa.")

Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Constructive algorithms
Skill types: Data structures

Starter code:

Solutions:
from sys import stdin
from sys import exit
live = True
if not live:
	stdin = open('data.in', 'r')
(n, m) = list(map(int, stdin.readline().strip().split()))
line = list(stdin.readline().strip())
ans = 0
listAns = []
for it in range(1, n):
	if line[it] == '.' and line[it - 1] == '.':
		ans += 1
for it in range(m):
	q = list(stdin.readline().strip().split())
	pos = int(q[0]) - 1
	s = str(q[1])
	if line[pos] == '.' and s != '.':
		if pos - 1 >= 0 and line[pos - 1] == '.':
			ans -= 1
		if pos + 1 < n and line[pos + 1] == '.':
			ans -= 1
	elif line[pos] != '.' and s == '.':
		if pos - 1 >= 0 and line[pos - 1] == '.':
			ans += 1
		if pos + 1 < n and line[pos + 1] == '.':
			ans += 1
	listAns += [ans]
	line[pos] = s
print(' '.join(map(str, listAns)))
if not live:
	stdin.close()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, t) = map(int, input().split())
s = list(input())
cnt = 0
for i in range(n):
	if i < n - 1 and s[i] + s[i + 1] == '..':
		cnt += 1
for _ in range(t):
	(p, ch) = input().split()
	p = int(p)
	if s[p - 1] == '.' and ch == '.':
		pass
	else:
		if s[p - 1] == '.':
			if (p < n and s[p] == '.') and (p > 1 and s[p - 2]) == '.':
				cnt -= 2
			elif p < n and s[p] == '.' or (p > 1 and s[p - 2] == '.'):
				cnt -= 1
		elif s[p - 1] != '.' and ch != '.':
			pass
		elif (p > 1 and s[p - 2] == '.') and (p < n and s[p] == '.'):
			cnt += 2
		elif p > 1 and s[p - 2] == '.' or (p < n and s[p] == '.'):
			cnt += 1
		s[p - 1] = ch
	print(cnt)


from sys import stdin, stdout
input = stdin.readline
from itertools import tee
(n, m) = map(int, input().split())
(i1, i2) = tee((c == '.' for c in 'a' + input() + 'a'))
prev = False
res = 0
s = bytearray(i1)
for c in i2:
	res += c and prev
	prev = c

def calc(s, res):
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc(s, res)))


from sys import stdin, stdout
input = stdin.readline
(a, b) = map(int, input().split())
n = list(input())
k = 0
for i in range(a - 1):
	if n[i] == '.' and n[i + 1] == '.':
		k += 1
while b > 0:
	b -= 1
	x = input().split()
	(i, l) = (int(x[0]), x[1])
	j = n[i - 1]
	n[i - 1] = l
	if j == '.' and l != '.':
		if i != 1 and n[i - 2] == '.':
			k -= 1
		if i != a and n[i] == '.':
			k -= 1
	elif j != '.' and l == '.':
		if i != 1 and n[i - 2] == '.':
			k += 1
		if i != a and n[i] == '.':
			k += 1
	stdout.write(str(k) + '\n')


import sys
fin = sys.stdin
[n, m] = [int(x) for x in fin.readline().split()]
s = [x == '.' for x in fin.readline().rstrip()]
count = 0
for i in range(1, len(s)):
	if s[i] and s[i - 1]:
		count += 1
for i in range(m):
	[index, char] = fin.readline().split()
	index = int(index) - 1
	if s[index] and char != '.':
		if index > 0 and s[index - 1]:
			count -= 1
		if index < n - 1 and s[index + 1]:
			count -= 1
		s[index] = False
	elif not s[index] and char == '.':
		if index > 0 and s[index - 1]:
			count += 1
		if index < n - 1 and s[index + 1]:
			count += 1
		s[index] = True
	print(count)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
s = list(input()[:-1])
if n == 1:
	for _ in range(m):
		print(0)
	exit()
ans = 0
cnt = 0
for i in range(n):
	if s[i] == '.':
		cnt += 1
	else:
		ans += max(0, cnt - 1)
		cnt = 0
ans += max(0, cnt - 1)
for _ in range(m):
	(x, c) = input().split()
	x = int(x)
	x -= 1
	if c == '.' and s[x] != '.':
		if x == 0:
			if s[x + 1] == '.':
				ans += 1
		elif x == n - 1:
			if s[x - 1] == '.':
				ans += 1
		else:
			if s[x - 1] == '.':
				ans += 1
			if s[x + 1] == '.':
				ans += 1
	elif c != '.' and s[x] == '.':
		if x == 0:
			if s[x + 1] == '.':
				ans -= 1
		elif x == n - 1:
			if s[x - 1] == '.':
				ans -= 1
		else:
			if s[x - 1] == '.':
				ans -= 1
			if s[x + 1] == '.':
				ans -= 1
	s[x] = c
	print(ans)


(n, m) = map(int, input().split())
a = list(input())
res = 0
b = []
for i in range(1, n):
	if a[i] + a[i - 1] == '..':
		res += 1
for i in range(m):
	(g, c) = input().split()
	p = int(g) - 1
	if p > 0 and a[p - 1] + a[p] == '..':
		res -= 1
	if p + 1 < n and a[p + 1] + a[p] == '..':
		res -= 1
	a[p] = c
	if p > 0 and a[p - 1] + a[p] == '..':
		res += 1
	if p + 1 < n and a[p + 1] + a[p] == '..':
		res += 1
	b.append(str(res))
print(' '.join(b))


(n, m) = list(map(int, input().split()))
s = [i for i in input()]
ans = 0
for i in range(1, n):
	if s[i - 1] == '.' and s[i] == '.':
		ans += 1
output = []
for i in range(m):
	l1 = input().split()
	(ind, ch) = (int(l1[0]) - 1, l1[1])
	if s[ind] == ch or (s[ind] != '.' and ch != '.'):
		output.append(str(ans))
		output.append('\n')
		continue
	if s[ind] != '.':
		if ind - 1 >= 0:
			if s[ind - 1] == '.':
				ans += 1
		if ind + 1 < n:
			if s[ind + 1] == '.':
				ans += 1
	elif s[ind] == '.':
		if ind - 1 >= 0:
			if s[ind - 1] == '.':
				ans -= 1
		if ind + 1 < n:
			if s[ind + 1] == '.':
				ans -= 1
	s[ind] = ch
	output.append(str(ans))
	output.append('\n')
print(''.join(output))


[n, m] = [int(i) for i in input().split()]
d = input()
s = []
for k in range(len(d)):
	s.append(d[k])
start = 0
ctr = 0
ans = 0
for w in range(len(s)):
	if s[w] == '.':
		if start == 0:
			start = 1
			ctr += 1
		else:
			ctr += 1
	elif start == 1:
		start = 0
		if ctr >= 2:
			ans += ctr - 1
		ctr = 0
if ctr >= 2:
	ans += ctr - 1
if n == 1:
	for h in range(m):
		a = input().split()
		x = int(a[0])
		c = a[1]
		print(0)
else:
	pr_arr = []
	for i in range(m):
		a = input().split()
		x = int(a[0])
		c = a[1]
		if s[x - 1] == '.' and c != '.':
			if x - 1 == 0 and s[x] == '.':
				ans = max(0, ans - 1)
				pr_arr.append(ans)
			elif x - 1 == n - 1 and s[x - 2] == '.':
				ans = max(0, ans - 1)
				pr_arr.append(ans)
			elif x - 1 != 0 and x - 1 != n - 1 and (s[x] == '.') and (s[x - 2] != '.'):
				ans = max(0, ans - 1)
				pr_arr.append(ans)
			elif x - 1 != 0 and x - 1 != n - 1 and (s[x] != '.') and (s[x - 2] == '.'):
				ans = max(0, ans - 1)
				pr_arr.append(ans)
			elif x - 1 != 0 and x - 1 != n - 1 and (s[x] == '.') and (s[x - 2] == '.'):
				ans = max(0, ans - 2)
				pr_arr.append(ans)
			else:
				pr_arr.append(ans)
		elif c == '.':
			if s[x - 1] == '.':
				pr_arr.append(ans)
			elif x - 1 == 0 and s[x] == '.':
				ans = max(0, ans + 1)
				pr_arr.append(ans)
			elif x - 1 == n - 1 and s[x - 2] == '.':
				ans = max(0, ans + 1)
				pr_arr.append(ans)
			elif x - 1 != 0 and x - 1 != n - 1 and (s[x] == '.') and (s[x - 2] != '.'):
				ans = max(0, ans + 1)
				pr_arr.append(ans)
			elif x - 1 != 0 and x - 1 != n - 1 and (s[x] != '.') and (s[x - 2] == '.'):
				ans = max(0, ans + 1)
				pr_arr.append(ans)
			elif x - 1 != 0 and x - 1 != n - 1 and (s[x] == '.') and (s[x - 2] == '.'):
				ans = max(0, ans + 2)
				pr_arr.append(ans)
			else:
				pr_arr.append(ans)
		else:
			pr_arr.append(ans)
		s[x - 1] = c
	for t in range(len(pr_arr)):
		print(pr_arr[t])


from sys import stdin, stdout
input = stdin.readline
from itertools import tee
(n, m) = map(int, input().split())
(i1, i2, i3) = tee((c == '.' for c in 'a' + input() + 'a'), 3)
next(i1)
res = sum((a and b for (a, b) in zip(i1, i2)))
s = bytearray(i3)

def calc(s, res):
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc(s, res)))


import itertools as it
import bisect
import sys
DOT = '.'
BAR = '|'

def solve(s, pairs):
	n = len(s)
	xs = [BAR] + [DOT if c == DOT else BAR for c in s] + [BAR]
	idx_char_pairs = [(int(x), DOT if c == DOT else BAR) for (x, c) in pairs]
	counts = [sum((1 for _ in iterable)) for (c, iterable) in it.groupby(xs) if c == DOT]
	total = sum(counts) - len(counts)
	n = len(xs)
	result = []
	for (idx, c) in idx_char_pairs:
		if xs[idx] == c:
			pass
		elif xs[idx] == DOT:
			xs[idx] = BAR
			if xs[idx - 1] == xs[idx + 1] == DOT:
				total -= 2
			elif xs[idx - 1] == DOT or xs[idx + 1] == DOT:
				total -= 1
			else:
				pass
		elif xs[idx] == BAR:
			xs[idx] = DOT
			if xs[idx - 1] == xs[idx + 1] == DOT:
				total += 2
			elif xs[idx - 1] == DOT or xs[idx + 1] == DOT:
				total += 1
			else:
				pass
		result.append(total)
	return result

def solve_slow(s, pairs):
	idx_char_pairs = [(int(x) - 1, '.' if c == '.' else 'x') for (x, c) in pairs]
	ss = list(s)
	result = []
	for (idx, c) in idx_char_pairs:
		ss[idx] = c
		dot_stepss = [sum((1 for _ in iterable)) for (cc, iterable) in it.groupby(ss) if cc == '.']
		out = sum((cnt - 1 for cnt in dot_stepss))
		result.append(out)
	return result

def print_stderr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def main():
	[n, m] = [int(i) for i in input().strip().split()]
	s = input().strip()
	assert len(s) == n
	xc_pairs = [input().strip().split() for _ in range(m)]
	result = solve(s, xc_pairs)
	for x in result:
		print(x)
main()


from sys import stdin, stdout
input = stdin.readline
import operator
from array import array
(n, m) = map(int, input().split())

def calc():
	s = array('B', [0])
	s.extend((c == '.' for c in input()))
	res = sum(map(operator.mul, s[1:], s))
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc()))


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = stdin.readline().strip()
arr = [0 for i in range(n)]
arr1 = [0 for i in range(n)]
tot = 0
for i in range(n):
	if s[i] == '.':
		arr[i] += arr[i - 1] + 1
	else:
		tot += max(arr[i - 1] - 1, 0)
arr1[-1] = arr[-1]
for i in range(n - 2, -1, -1):
	if arr[i] != 0 and arr[i] < arr[i + 1]:
		arr1[i] = arr1[i + 1]
	if arr[i + 1] == 0:
		arr1[i] = arr[i]
tot += max(arr[-1] - 1, 0)
s = list(s)
for i in range(m):
	(a, b) = stdin.readline().strip().split()
	a = int(a) - 1
	if b != '.':
		if s[a] != '.':
			print(tot)
			s[a] = b
			continue
		l = 1
		if a - 1 < 0 or s[a - 1] != '.':
			l = 0
		r = 1
		if a + 1 >= n or s[a + 1] != '.':
			r = 0
		if l + r == 2:
			tot -= 2
		elif l == 1:
			tot -= 1
		elif r == 1:
			tot -= 1
		print(tot)
	else:
		if s[a] == '.':
			print(tot)
			s[a] = b
			continue
		l = 1
		if a - 1 < 0 or s[a - 1] != '.':
			l = 0
		r = 1
		if a + 1 >= n or s[a + 1] != '.':
			r = 0
		if l + r == 2:
			tot += 2
		elif l == 1:
			tot += 1
		elif r == 1:
			tot += 1
		print(tot)
	s[a] = b


from sys import stdin, stdout
input = stdin.readline
import operator
(n, m) = map(int, input().split())

def calc():
	s = bytearray((c == '.' for c in 'a' + input()))
	res = sum(map(operator.mul, s[1:], s))
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc()))


import sys
(n, m) = map(int, sys.stdin.readline().split())
s = list(sys.stdin.readline())
queries = iter(sys.stdin.read().split())
queries = zip(queries, queries)
cnt = sum((a == b == '.' for (a, b) in zip(s, s[1:])))
ans = []
for (x, c) in queries:
	x = int(x) - 1
	if c == '.':
		if s[x] != '.':
			s[x] = c
			if x - 1 >= 0 and s[x - 1] == '.':
				cnt += 1
			if x + 1 < n and s[x + 1] == '.':
				cnt += 1
	elif s[x] == '.':
		s[x] = c
		if x - 1 >= 0 and s[x - 1] == '.':
			cnt -= 1
		if x + 1 < n and s[x + 1] == '.':
			cnt -= 1
	ans.append(str(cnt))
print('\n'.join(ans))


from sys import stdin, stdout
input = stdin.readline
import operator
(n, m) = map(int, input().split())
s = [False] + [c == '.' for c in input()] + [False]
res = sum(map(operator.mul, s[1:], s[:-1]))
res_list = list()
for i in range(m):
	(x, c) = input().split()
	x = int(x)
	nc = c == '.'
	if s[x] != nc:
		diff = s[x - 1] + s[x + 1]
		res += (-diff, diff)[nc]
		s[x] = nc
	res_list.append(res)
stdout.write('\n'.join(map(str, res_list)))


(n, m) = map(int, input().split())
s = [True] + [c != '.' for c in input()] + [True]
ans = sum((s[i] == s[i + 1] == 0 for i in range(1, n + 1)))
inp = [0] * m
for i in range(m):
	inp[i] = input()
out = [0] * m
for i in range(m):
	(pos, c) = inp[i].split()
	(pos, c) = (int(pos), c != '.')
	if not s[pos]:
		if c:
			ans -= 2 - (s[pos - 1] + s[pos + 1])
	elif not c:
		ans += 2 - (s[pos - 1] + s[pos + 1])
	s[pos] = c
	out[i] = ans
print('\n'.join(map(str, out)))
import time, sys
sys.stderr.write('{0:.3f} ms\n'.format(time.clock() * 1000))


from sys import stdin, stdout
input = stdin.readline
from itertools import tee, chain
(n, m) = map(int, input().split())
(i1, i2, i3) = tee((c == '.' for c in input()), 3)
s = bytearray(chain([False], i1, [False]))
res = sum(map(all, zip(chain([False], i2), chain(i3, [False]))))

def calc(s, res):
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc(s, res)))


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())

def calc():
	s = bytearray((c == '.' for c in 'a' + input()))
	res = sum((a and b for (a, b) in zip(s[1:], s)))
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if nc and (not s[x]):
			res += s[x - 1] + s[x + 1]
		if not nc and s[x]:
			res -= s[x - 1] + s[x + 1]
		s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc()))


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
s = list(input().rstrip())
ans = 0
cnt = 0
for i in range(1, n):
	if s[i] == s[i - 1] == '.':
		cnt += 1
	else:
		ans += cnt
		cnt = 0
if cnt > 0:
	ans += cnt
for _ in range(m):
	(x, c) = input().rstrip().split()
	x = int(x) - 1
	if c == '.' and s[x] != '.':
		if x == 0:
			if n >= 2 and s[1] == '.':
				ans += 1
		elif x == n - 1:
			if n >= 2 and s[n - 2] == '.':
				ans += 1
		elif s[x - 1] == s[x + 1] == '.':
			ans += 2
		elif s[x - 1] == '.' or s[x + 1] == '.':
			ans += 1
	elif c != '.' and s[x] == '.':
		if x == 0:
			if n >= 2 and s[1] == '.':
				ans -= 1
		elif x == n - 1:
			if n >= 2 and s[n - 2] == '.':
				ans -= 1
		elif s[x - 1] == s[x + 1] == '.':
			ans -= 2
		elif s[x - 1] == '.' or s[x + 1] == '.':
			ans -= 1
	s[x] = c
	print(ans)


import sys
sys.setrecursionlimit(1000000)

def solve():
	(n, m) = rv()
	s = list(input())
	res = [0] * m
	helper = list()
	for i in range(n):
		if s[i] == '.':
			if i == 0:
				helper.append(1)
			elif s[i - 1] == '.':
				helper[-1] += 1
			else:
				helper.append(1)
	initval = 0
	for val in helper:
		initval += val - 1
	for query in range(m):
		(index, replace) = input().split()
		index = int(index) - 1
		if s[index] == '.' and replace == '.' or (s[index] != '.' and replace != '.'):
			res[query] = initval
		else:
			sidedots = 0
			if index > 0:
				if s[index - 1] == '.':
					sidedots += 1
			if index < n - 1:
				if s[index + 1] == '.':
					sidedots += 1
			if s[index] == '.':
				res[query] = initval - sidedots
				initval -= sidedots
			else:
				res[query] = initval + sidedots
				initval += sidedots
		s[index] = replace
	print('\n'.join(map(str, res)))

def rv():
	return list(map(int, input().split()))

def rl(n):
	return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
solve()


from sys import stdin
input = stdin.readline
(n, m) = list(map(int, input().split()))
s = list(((0, 1)[c == '.'] for c in list(input())))
res = 0
cnt = 0
for k in s:
	if k == 1:
		cnt += 1
	else:
		res += max(cnt - 1, 0)
		cnt = 0
res += max(0, cnt - 1)
for i in range(m):
	(x, c) = input().split()
	x = int(x)
	nc = (0, 1)[c == '.']
	if s[x - 1] != nc:
		diff = 0
		if x < n:
			if s[int(x)] == 1:
				diff += 1
		if x > 1:
			if s[int(x - 2)] == 1:
				diff += 1
		if nc == 1:
			res += diff
		else:
			res -= diff
	s[x - 1] = nc
	print(res)


import sys

def main():
	(n, m) = map(int, sys.stdin.readline().strip().split(' '))
	s = list(input())
	k = 0
	for i in range(n - 1):
		if s[i] == '.' and s[i + 1] == '.':
			k += 1
	for j in range(m):
		(xi, ci) = sys.stdin.readline().strip().split(' ')
		xi = int(xi) - 1
		prev = s[xi]
		s[xi] = ci
		if prev == '.' and ci != '.':
			if xi + 1 != 1 and s[xi - 1] == '.':
				k -= 1
			if xi != n - 1 and s[xi + 1] == '.':
				k -= 1
		elif prev != '.' and ci == '.':
			if xi + 1 != 1 and s[xi - 1] == '.':
				k += 1
			if xi != n - 1 and s[xi + 1] == '.':
				k += 1
		sys.stdout.write('{}\n'.format(k))
main()


from sys import stdin

def solve():
	(n, m) = list(map(int, stdin.readline().strip().split()))
	s = ['a'] + list(stdin.readline().strip()) + ['a']
	points = 0
	blocks = 0
	isbl = 0
	for i in range(len(s)):
		if s[i] == '.':
			isbl = 1
			points += 1
		elif isbl:
			blocks += 1
			isbl = 0
	res = [0] * m
	for i in range(m):
		[x, c] = list(stdin.readline().strip().split())
		x = int(x)
		if c == '.' and s[x] == '.' or (c != '.' and s[x] != '.'):
			pass
		elif c == '.':
			points += 1
			if s[x - 1] == '.' and s[x + 1] == '.':
				blocks -= 1
			elif s[x - 1] != '.' and s[x + 1] != '.':
				blocks += 1
		else:
			points -= 1
			if s[x - 1] == '.' and s[x + 1] == '.':
				blocks += 1
			elif s[x - 1] != '.' and s[x + 1] != '.':
				blocks -= 1
		s[x] = c
		res[i] = str(points - blocks)
	print(' '.join(res))
	stdin.close()
solve()


(n, m) = (int(t) for t in input().split())
s = [c for c in input()]
fs = 0
for i in range(1, len(s)):
	if s[i] == '.' and s[i - 1] == '.':
		fs += 1
out = []
for k in range(m):
	t = input().split()
	i = int(t[0]) - 1
	c = t[1]
	if (c == '.') != (s[i] == '.'):
		if i - 1 > -1 and s[i - 1] == '.':
			fs += 1 if c == '.' else -1
		if i + 1 < len(s) and s[i + 1] == '.':
			fs += 1 if c == '.' else -1
	s[i] = c
	out.append(str(fs))
	out.append('\n')
print(''.join(out), end='')


__author__ = 'andrei'

def solve(string, updates):
	count = sum(string) - sum([not string[i] and string[i + 1] for i in range(len(string) - 1)])
	for (pos, val) in updates:
		if string[pos] != val:
			sign = 1 if val else -1
			count += sign
			count += sign * (string[pos - 1] and string[pos + 1])
			count -= sign * (not string[pos - 1] and (not string[pos + 1]))
		string[pos] = val
		yield count

def read_input():
	from sys import stdin
	input_lines = stdin.readline
	(n, m) = map(int, input_lines().split())
	string = [False] + [c == '.' for c in input_lines()] + [False]

	def parse_update(line):
		(pos, val) = line.split()
		return (int(pos), val == '.')
	updates = (parse_update(input_lines()) for _ in range(m))
	return (string, updates)

def main():
	(string, updates) = read_input()
	for x in solve(string, updates):
		print(x)
main()


import sys
(length, z) = list(sys.stdin.readline().split())
s = list(sys.stdin.readline())
length = int(length) - 1
minn = 0
output = str()
for i in range(length):
	if s[i] == s[i + 1] == '.':
		minn += 1
for i in range(int(z)):
	(x, c) = input().split()
	x = int(x) - 1
	if c != '.':
		if s[x] == '.':
			if x > 0 and s[x - 1] == '.':
				minn -= 1
			if x < length and s[x + 1] == '.':
				minn -= 1
			s[x] = c
	elif s[x] != '.':
		if x > 0 and s[x - 1] == '.':
			minn += 1
		if x < length and s[x + 1] == '.':
			minn += 1
		s[x] = c
	output += str(minn)
	output += '\n'
sys.stdout.write(output)


from sys import stdin
(_, nQueries) = map(int, stdin.readline().split())
s = 'a' + stdin.readline().rstrip() + 'a'
seg = [1 if ch == '.' else 0 for (_, ch) in enumerate(s)]
cnt = 0
segCnt = 0
for (i, val) in enumerate(seg):
	cnt += val
	segCnt += val == 1 and seg[i - 1] == 0
ret = []
for _ in range(nQueries):
	(pos, ch) = stdin.readline().split()
	pos = int(pos)
	if ch == '.' and seg[pos] == 0:
		seg[pos] = 1
		cnt += 1
		if seg[pos - 1] == seg[pos + 1] == 0:
			segCnt += 1
		elif seg[pos - 1] == seg[pos + 1] == 1:
			segCnt -= 1
	elif ch != '.' and seg[pos] == 1:
		seg[pos] = 0
		cnt -= 1
		if seg[pos - 1] == seg[pos + 1] == 0:
			segCnt -= 1
		elif seg[pos - 1] == 1 and seg[pos + 1] == 1:
			segCnt += 1
	ret.append(cnt - segCnt)
print('\n'.join(map(str, ret)))


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
s = [False] + [c == '.' for c in list(input())] + [False]
res = 0
cnt = 0
for k in s:
	if k == 1:
		cnt += 1
	else:
		res += max(cnt - 1, 0)
		cnt = 0
res += max(0, cnt - 1)
res_list = list()
for i in range(m):
	(x, c) = input().split()
	x = int(x)
	nc = c == '.'
	if s[x] != nc:
		diff = int(s[x - 1]) + int(s[x + 1])
		if nc == 1:
			res += diff
		else:
			res -= diff
	s[x] = nc
	res_list.append(res)
stdout.write('\n'.join(map(str, res_list)))


import collections
import bisect

def f():
	(n, m) = [int(c) for c in input().split()]
	s = list(input())
	ll = []
	start = 0
	length = 0
	inside = False
	cc = 0
	for i in range(len(s)):
		if s[i] == '.':
			if not inside:
				inside = True
			length += 1
		elif inside:
			cc += length - 1
			length = 0
			inside = False
	if inside:
		cc += length - 1
	res = [0] * m
	for i in range(m):
		line = input().split()
		j = int(line[0]) - 1
		c = line[1]
		if c == '.' and s[j] == '.' or (c != '.' and s[j] != '.'):
			res[i] = cc
		else:
			e1 = False
			e2 = False
			if j > 0 and s[j - 1] == '.':
				e1 = True
			if j < n - 1 and s[j + 1] == '.':
				e2 = True
			if e1 and e2:
				cc += 2 if c == '.' else -2
			elif e1 or e2:
				cc += 1 if c == '.' else -1
			s[j] = c
			res[i] = cc
	for r in res:
		print(r)
f()


from sys import stdin, stdout
input = stdin.readline
from itertools import tee
(n, m) = map(int, input().split())
(s1, s2) = tee((c == '.' for c in 'a' + input() + 'a'))

def precalc():
	res = 0
	prev = False
	for c in s1:
		res += c and prev
		prev = c
	return res

def calc():
	global res
	s = bytearray(s2)
	res = precalc()
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc()))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
s = list(input())
fs = 0
for i in range(n - 1):
	if s[i] == s[i + 1] and s[i] == '.':
		fs += 1
for i in range(m):
	(x, c) = input().split()
	x = int(x) - 1
	if s[x] != '.':
		if c == '.':
			if x != 0 and s[x - 1] == '.':
				fs += 1
			if x != n - 1 and s[x + 1] == '.':
				fs += 1
	elif c != '.':
		if x != 0 and s[x - 1] == '.':
			fs -= 1
		if x != n - 1 and s[x + 1] == '.':
			fs -= 1
	s[x] = c
	print(fs)


from sys import stdin
input = stdin.readline

class PointReplacement:

	def __init__(self, s):
		self.s = list(s)
		self.replacements = 0

	def initialize(self):
		cnt = 0
		for idx in range(1, len(s)):
			if self.s[idx] == self.s[idx - 1] == '.':
				cnt += 1
			else:
				self.replacements += cnt
				cnt = 0
		if cnt > 0:
			self.replacements += cnt

	def replace(self, index, char):
		if len(self.s) == 1:
			return
		idx = index - 1
		idxVal = self.s[idx]
		if idxVal == '.' and char != '.':
			if idx == 0:
				if self.s[idx + 1] == '.':
					self.replacements -= 1
			elif idx == len(self.s) - 1:
				if self.s[idx - 1] == '.':
					self.replacements -= 1
			elif self.s[idx + 1] == self.s[idx - 1] == '.':
				self.replacements -= 2
			elif self.s[idx + 1] == '.' or self.s[idx - 1] == '.':
				self.replacements -= 1
		if idxVal != '.' and char == '.':
			if idx == 0:
				if self.s[idx + 1] == '.':
					self.replacements += 1
			elif idx == len(self.s) - 1:
				if self.s[idx - 1] == '.':
					self.replacements += 1
			elif self.s[idx + 1] == self.s[idx - 1] == '.':
				self.replacements += 2
			elif self.s[idx + 1] == '.' or self.s[idx - 1] == '.':
				self.replacements += 1
		self.s[idx] = char
n = input().split()
number_replacements = int(n[1])
s = input()
replacer = PointReplacement(s)
replacer.initialize()
for _ in range(number_replacements):
	replacement = input().split()
	replacer.replace(int(replacement[0]), replacement[1])
	print(replacer.replacements)


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(n, m) = Neo()
s = ['*'] + list(input()) + ['*']
t = 0
for (i, j) in zip(s, s[1:]):
	if i + j == '..':
		t += 1
for i in range(m):
	(ind, c) = input().split()
	ind = int(ind)
	if c == '.':
		if s[ind] != '.':
			if s[ind - 1] + s[ind + 1] == '..':
				t += 2
				s[ind] = c
			elif s[ind - 1] == '.' or s[ind + 1] == '.':
				t += 1
				s[ind] = c
			else:
				s[ind] = c
	elif s[ind - 1] + s[ind] + s[ind + 1] == '...':
		t -= 2
		s[ind] = c
	elif s[ind - 1] + s[ind] == '..' or s[ind] + s[ind + 1] == '..':
		t -= 1
		s[ind] = c
	else:
		s[ind] = c
	print(t)


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd
import bisect
import sys
import copy

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
s = input()
cnt = 0
for i in range(len(s) - 1):
	if s[i] == '.' and s[i + 1] == '.':
		cnt += 1
arr = []
for i in range(len(s)):
	arr.append(s[i])
for i in range(m):
	(a, b) = input().split()
	a = int(a)
	a -= 1
	if b == '.':
		if arr[a] != '.':
			if a + 1 <= n - 1 and arr[a + 1] == '.':
				cnt += 1
			if a - 1 >= 0 and arr[a - 1] == '.':
				cnt += 1
		arr[a] = b
	else:
		if arr[a] == '.':
			if a + 1 <= n - 1 and arr[a + 1] == '.':
				cnt -= 1
			if a - 1 >= 0 and arr[a - 1] == '.':
				cnt -= 1
		arr[a] = b
	print(cnt)


(n, m) = map(int, input().split())
s = [c != '.' for c in input()] + [1]
k = sum((s[i] == 0 and s[i + 1] != 1 for i in range(n)))
t = [0] * m
for i in range(m):
	(x, c) = input().split()
	(x, c) = (int(x) - 1, c != '.')
	d = s[x - 1] + s[x + 1] - 2
	k += (c - s[x]) * d
	(s[x], t[i]) = (c, k)
print('\n'.join(map(str, t)))


(n, m) = map(int, input().split())
s = ['a'] + list(input()) + ['a']
f = 0
flag = False
for i in s:
	if i == '.':
		f += 1
		flag = True
	elif flag:
		f -= 1
		flag = False
if flag == True:
	f -= 1
answer = []
for i in range(m):
	(x, c) = input().split()
	x = int(x)
	if s[x] == c or (s[x] != '.' and c != '.'):
		answer.append(f)
		continue
	s[x] = c
	if s[x - 1] == '.' and s[x + 1] != '.':
		if c == '.':
			f += 1
		else:
			f -= 1
	if s[x - 1] != '.' and s[x + 1] == '.':
		if c == '.':
			f += 1
		else:
			f -= 1
	if s[x - 1] == '.' and s[x + 1] == '.':
		if c == '.':
			f += 2
		else:
			f -= 2
	answer.append(f)
print('\n'.join(map(str, answer)))


from sys import stdin, stdout
input = stdin.readline
from itertools import tee, islice

def calc():
	(n, m) = map(int, input().split())
	(s1, s2, s3) = tee((c == '.' for c in 'a' + input() + 'a'), 3)
	s = bytearray(s1)
	res = sum((a and b for (a, b) in zip(islice(s2, 1, None), s3)))
	for i in range(m):
		(x, c) = input().split()
		x = int(x)
		nc = c == '.'
		if s[x] != nc:
			diff = s[x - 1] + s[x + 1]
			res += (-diff, diff)[nc]
			s[x] = nc
		yield str(res)
stdout.write('\n'.join(calc()))


import sys

def count(s):
	sm = 0
	ln = 0
	i = 0
	while i < len(s):
		cnt = 0
		while i < len(s) and s[i] == '.':
			cnt += 1
			i += 1
		if cnt > 1:
			sm += cnt
			ln += 1
		i += 1
	return sm - ln
(n, m) = map(int, sys.stdin.readline().split())
string = ['#'] + list(input()) + ['#']
ans = count(string)
arans = [0 for i in range(m)]
for _ in range(m):
	(i, s) = sys.stdin.readline().split()
	i = int(i)
	if s == '.':
		if string[i] == s:
			sys.stdout.write(str(ans) + '\n')
			continue
		string[i] = s
		if string[i + 1] == '.':
			ans += 1
		if string[i - 1] == '.':
			ans += 1
	else:
		if '.' != string[i]:
			sys.stdout.write(str(ans) + '\n')
			continue
		string[i] = s
		if string[i + 1] == '.':
			ans -= 1
		if string[i - 1] == '.':
			ans -= 1
	sys.stdout.write(str(ans) + '\n')


from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from sys import *

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
(n, m) = zzz()
arr = list(fast() + '***')
(k, res) = (0, [])
for i in range(n):
	if arr[i] == arr[i + 1] == '.':
		k += 1
for i in range(m):
	(x, y) = fast().split(' ')
	x = int(x) - 1
	if arr[x] == '.':
		if y != '.':
			if x > 0 and arr[x - 1] == '.':
				k -= 1
			if x < n - 1 and arr[x + 1] == '.':
				k -= 1
	elif y == '.':
		if x > 0 and arr[x - 1] == '.':
			k += 1
		if x < n - 1 and arr[x + 1] == '.':
			k += 1
	print(k)
	arr[x] = y


(n, m) = map(int, input().split())
s = input()
inp = [0] * m
for i in range(m):
	inp[i] = input()
a = [0] * (n + 2)
out = [0] * m
summ = 0
for i in range(1, n + 1):
	if s[i - 1] == '.':
		a[i] = 1
		if a[i - 1]:
			summ += 1
for i in range(m):
	(x, c) = inp[i].split()
	x = int(x)
	if c == '.':
		if not a[x]:
			a[x] = 1
			if a[x - 1]:
				summ += 1
			if a[x + 1]:
				summ += 1
	elif a[x]:
		a[x] = 0
		if a[x - 1]:
			summ -= 1
		if a[x + 1]:
			summ -= 1
	out[i] = summ
print('\n'.join(map(str, out)))


import sys
(n, m) = map(int, sys.stdin.readline().split())
arr = list(sys.stdin.readline())
count = cnt = 0
for i in arr:
	if i == '.':
		cnt += 1
	elif cnt != 0:
		count += cnt - 1
		cnt = 0
if cnt != 0:
	count += cnt - 1
i = m
while i:
	(x, c) = sys.stdin.readline().split()
	x = int(x) - 1
	if arr[x] == '.' and c != '.':
		if x - 1 >= 0 and x + 1 < n and (arr[x - 1] == '.' and arr[x + 1] == '.'):
			count -= 2
		elif x - 1 >= 0 and x + 1 < n and (arr[x - 1] == '.' or arr[x + 1] == '.'):
			count -= 1
		elif x - 1 >= 0:
			if arr[x - 1] == '.':
				count -= 1
		elif x + 1 < n:
			if arr[x + 1] == '.':
				count -= 1
	elif arr[x] != '.' and c == '.':
		if x - 1 >= 0 and x + 1 < n and (arr[x - 1] == '.' and arr[x + 1] == '.'):
			count += 2
		elif x - 1 >= 0 and x + 1 < n and (arr[x - 1] == '.' or arr[x + 1] == '.'):
			count += 1
		elif x - 1 >= 0:
			if arr[x - 1] == '.':
				count += 1
		elif x + 1 < n:
			if arr[x + 1] == '.':
				count += 1
	sys.stdout.write(str(count) + '\n')
	arr[x] = c
	i -= 1


(n, m) = map(int, input().split())
l = list(input())
k = 0
for i in range(n - 1):
	if l[i] == '.' and l[i + 1] == '.':
		k = k + 1
g = []
for i in range(m):
	(a, b) = map(str, input().split())
	a = int(a) - 1
	if b == '.' and l[a] != '.':
		if a - 1 >= 0:
			if l[a - 1] == '.':
				k = k + 1
		if a + 1 != n:
			if l[a + 1] == '.':
				k = k + 1
	if b != '.' and l[a] == '.':
		if a - 1 >= 0:
			if l[a - 1] == '.':
				k = k - 1
		if a + 1 != n:
			if l[a + 1] == '.':
				k = k - 1
	l[a] = b
	g.append(k)
print('\n'.join(map(str, g)))


(n, m) = map(int, input().split())
a = [x == '.' for x in input()] + [False]
k = sum([a[i] and a[i + 1] for i in range(n)])
t = [0] * m
for i in range(m):
	(x, c) = input().split()
	(x, c) = (int(x) - 1, c == '.')
	k -= (a[x] - c) * (a[x - 1] + a[x + 1])
	(a[x], t[i]) = (c, k)
print('\n'.join(map(str, t)))


import sys
import io
import re

def main():
	(n, m) = map(int, input().split())
	s = input()
	result = []
	count = 0
	for group in re.findall('\\.{2,}', s):
		count += len(group) - 1
	s = [' '] + list(s) + [' ']
	for _ in range(m):
		(pos, char) = input().split()
		pos = int(pos)
		effect = 0
		if s[pos - 1] == '.':
			effect += 1
		if s[pos + 1] == '.':
			effect += 1
		if char == '.' and s[pos] != '.':
			count += effect
		elif char != '.' and s[pos] == '.':
			count -= effect
		s[pos] = char
		result.append(count)
	result = '\n'.join(map(str, result))
	print(result)
	return result

def test_case_1():
	sys.stdin = io.StringIO('10 3\n.b..bz....\n1 h\n3 c\n9 f')
	expected = '4\n3\n1'
	actual = main()
	assert actual == expected

def test_case_2():
	sys.stdin = io.StringIO('4 4\n.cc.\n2 .\n3 .\n2 a\n1 a')
	expected = '1\n3\n1\n1'
	actual = main()
	assert actual == expected

def test_case_3():
	sys.stdin = io.StringIO('4 4\n.cc.\n4 .\n3 .\n2 a\n4 a')
	expected = '0\n1\n1\n0'
	actual = main()
	assert actual == expected
main()


from sys import stdin, stdout, stderr
(n, q) = map(int, stdin.readline().split())
a = stdin.readline()
ok = [0 for _ in range(n)]
ok.append(0)
ok.append(0)
number = 0
limit = 0
for i in range(n):
	if a[i] == '.':
		ok[i + 1] = 1
		number += 1
		if i == 0 or a[i - 1] != '.':
			limit += 1
print(' ')
for _ in range(q):
	z = [x for x in stdin.readline().split()]
	index = int(z[0])
	if z[1] == '.' and ok[index] == 1:
		stdout.write('%d\n' % (number - limit))
		continue
	if z[1] != '.' and ok[index] == 0:
		stdout.write('%d\n' % (number - limit))
		continue
	if z[1] == '.':
		number += 1
	else:
		number -= 1
	if ok[index - 1] and ok[index + 1] and (z[1] != '.'):
		limit += 1
	if ok[index - 1] and ok[index + 1] and (z[1] == '.'):
		limit -= 1
	if ok[index - 1] == 0 and ok[index + 1] == 0 and (z[1] == '.'):
		limit += 1
	if ok[index - 1] == 0 and ok[index + 1] == 0 and (z[1] != '.'):
		limit -= 1
	if z[1] == '.':
		ok[index] = 1
	else:
		ok[index] = 0
	stdout.write('%d\n' % (number - limit))


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def solve(s):
	z = 0
	ans = 0
	for item in s:
		if item == '.':
			z += 1
		elif z > 0:
			ans += z - 1
			z = 0
	if z:
		ans += z - 1
	return ans

def check(a, b, s, ans, n):
	if s[a] == '.' and b == '.':
		pass
	elif s[a] != '.' and b != '.':
		pass
	elif s[a] == '.' and b != '.':
		l = 0
		r = 0
		if a > 0 and s[a - 1] == '.':
			l = 1
		if a < n - 1 and s[a + 1] == '.':
			r = 1
		if l == 0 and r == 0:
			pass
		elif l == 1 and r == 1:
			ans -= 2
		elif l == 1 or r == 1:
			ans -= 1
		s[a] = b
	else:
		l = 0
		r = 0
		if a > 0 and s[a - 1] == '.':
			l = 1
		if a < n - 1 and s[a + 1] == '.':
			r = 1
		if l == 0 and r == 0:
			pass
		elif l == 1 and r == 1:
			ans += 2
		elif l == 1 or r == 1:
			ans += 1
		s[a] = b
	return ans

def main():
	(n, m) = map(int, input().split())
	s = list(input())
	ans = solve(s)
	for _ in range(m):
		(a, b) = input().split()
		a = int(a) - 1
		ans = check(a, b, s, ans, n)
		print(ans)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
s = list(input())
dots = 0
for i in range(n - 1):
	if s[i] == '.' and s[i + 1] == '.':
		dots += 1
for i in range(m):
	(ind, cha) = input().split()
	ind = int(ind)
	if cha == '.':
		if s[ind - 1] != '.':
			if ind < n:
				if s[ind] == '.':
					dots += 1
			if ind > 1:
				if s[ind - 2] == '.':
					dots += 1
	elif s[ind - 1] == '.':
		if ind < n:
			if s[ind] == '.':
				dots -= 1
		if ind > 1:
			if s[ind - 2] == '.':
				dots -= 1
	s[ind - 1] = cha
	stdout.write(str(dots) + '\n')


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
s = list(input())
ans = 0
for i in range(n - 1):
	if s[i] == '.' and s[i + 1] == '.':
		ans += 1
while m:
	m -= 1
	inp = input().split()
	index = int(inp[0]) - 1
	char = inp[1]
	if char == '.' and s[index] != '.':
		if index != 0 and index != n - 1 and (s[index + 1] == '.') and (s[index - 1] == '.'):
			ans += 2
		elif index != 0 and s[index - 1] == '.' or (index != n - 1 and s[index + 1] == '.'):
			ans += 1
	elif s[index] == '.' and char != '.':
		if index != 0 and index != n - 1 and (s[index + 1] == '.') and (s[index - 1] == '.'):
			ans -= 2
		elif index != 0 and s[index - 1] == '.' or (index != n - 1 and s[index + 1] == '.'):
			ans -= 1
	s[index] = char
	print(ans)


from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())

def bfs(deg, vis, cur):
	qu = deque([])
	qu.append(cur)
	while qu:
		x = qu.popleft()
		vis[x] = 1
		for i in deg[x]:
			if vis[i] == 0:
				qu.append(i)
(n, m) = ma()
s = input().rstrip('\n')
r = []
pr = []
for i in s:
	if i == '.':
		pr.append(0)
	else:
		pr.append(1)
pr.append(1)
tot = 0
for i in range(n):
	if pr[i] == 0 and pr[i + 1] == 0:
		tot += 1
for i in range(m):
	x = input().split()
	(x, c) = (int(x[0]), x[1])
	x -= 1
	z = 0
	if c != '.':
		z = 1
	tot += (z - pr[x]) * (pr[x - 1] + pr[x + 1] - 2)
	r.append(tot)
	pr[x] = z
for i in r:
	print(i)


def main():
	(n, m) = map(int, input().split())
	(l, res) = ([False], [])
	l.extend((c == '.' for c in input()))
	l.append(False)
	f = sum((a and b for (a, b) in zip(l, l[1:])))
	sf = str(f)
	for _ in range(m):
		(a, b) = input().split()
		(x, y) = (int(a), b == '.')
		if l[x] != y:
			if y:
				l[x] = True
				f += l[x - 1] + l[x + 1]
			else:
				l[x] = False
				f -= l[x - 1] + l[x + 1]
			sf = str(f)
		res.append(sf)
	print('\n'.join(res))
main()


from sys import stdin
input = stdin.readline
(n, m) = list(map(int, input().split()))
string = list(input())
total_ans = 0
for i in range(n - 1):
	if string[i] == '.' and string[i + 1] == '.':
		total_ans += 1

def factor(ps, ch):
	f = 0
	if ch == '.' and string[ps] == '.':
		return 0
	if ch != '.' and string[ps] != '.':
		return 0
	if 0 <= ps - 1 and string[ps - 1] == '.':
		f += 1
	if ps + 1 < n and string[ps + 1] == '.':
		f += 1
	if ch == '.':
		return +f
	else:
		return -f
ans = []
for _ in range(m):
	(ps, ch) = list(map(str, input().split()))
	ps = int(ps) - 1
	total_ans += factor(ps, ch)
	string[ps] = ch
	print(total_ans)
	ans.append(str(total_ans))


from sys import stdin, setrecursionlimit
import math

def get_required(string):
	s = 0
	q = 0
	start = 0
	for i in range(len(string)):
		if string[i] == '.':
			s += 1
			if start == 0:
				q += 1
				start = 1
		else:
			start = 0
	return (s, q)
(n, m) = list(map(int, stdin.readline().split()))
string = list(stdin.readline().strip())
(s, q) = get_required(string)
for _ in range(m):
	(index, c) = list(stdin.readline().split())
	index = int(index) - 1
	if string[index] == '.' and c != '.':
		if index - 1 >= 0 and index + 1 < n:
			if string[index - 1] == '.' and string[index + 1] == '.':
				q += 1
			elif string[index - 1] != '.' and string[index + 1] != '.':
				q -= 1
		elif index == 0 and index + 1 < n:
			if string[index + 1] != '.':
				q -= 1
		elif index == n - 1 and index - 1 >= 0:
			if string[index - 1] != '.':
				q -= 1
		elif len(string) == 1:
			q -= 1
		s -= 1
		print(s - q)
	elif string[index] != '.' and c == '.':
		if index - 1 >= 0 and index + 1 < n:
			if string[index - 1] == '.' and string[index + 1] == '.':
				q -= 1
			elif string[index - 1] != '.' and string[index + 1] != '.':
				q += 1
		elif index == 0 and index + 1 < n:
			if string[index + 1] != '.':
				q += 1
		elif index == n - 1 and index - 1 >= 0:
			if string[index - 1] != '.':
				q += 1
		elif len(string) == 1:
			q += 1
		s += 1
		print(s - q)
	else:
		print(s - q)
	string[index] = c


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
s = list(input())
pos = []
f0 = 0
con_pc = 0
for i in range(n):
	if s[i] == '.':
		pos.append(i)
		con_pc += 1
		if con_pc >= 2:
			f0 += 1
	else:
		con_pc = 0
r = []
for _ in range(m):
	(xi, ci) = input().strip().split()
	xi = int(xi) - 1
	if s[xi] != '.' and ci == '.' or (s[xi] == '.' and ci != '.'):
		s[xi] = ci
		if ci == '.':
			if xi == 0:
				if n >= 2 and s[1] == '.':
					f0 += 1
			elif xi == n - 1:
				if n >= 2 and s[n - 2] == '.':
					f0 += 1
			elif n >= 3:
				if s[xi - 1] == '.' and s[xi + 1] == '.':
					f0 += 2
				elif s[xi - 1] == '.' or s[xi + 1] == '.':
					f0 += 1
		elif xi == 0:
			if n >= 2 and s[1] == '.':
				f0 -= 1
		elif xi == n - 1:
			if n >= 2 and s[n - 2] == '.':
				f0 -= 1
		elif n >= 3:
			if s[xi - 1] == '.' and s[xi + 1] == '.':
				f0 -= 2
			elif s[xi - 1] == '.' or s[xi + 1] == '.':
				f0 -= 1
	r.append(f0)
print('\n'.join(map(str, r)))


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(sys.stdin.readline())

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, nQ) = In()
		l = list(Sn())
		cnt = 0
		for i in range(n - 1):
			if l[i] == '.' and l[i + 1] == '.':
				cnt += 1
		for i in range(nQ):
			(a, b) = Sn().split()
			a = int(a) - 1
			if l[a] == '.':
				if b == '.':
					print(cnt)
					continue
				if a == 0 and a + 1 < n:
					if l[a + 1] == '.':
						cnt -= 1
					l[a] = b
				elif a == n - 1 and a - 1 >= 0:
					if l[a - 1] == '.':
						cnt -= 1
					l[a] = b
				elif a - 1 >= 0 and a + 1 < n:
					if l[a - 1] == '.':
						cnt -= 1
					if l[a + 1] == '.':
						cnt -= 1
					l[a] = b
			elif b == '.':
				if l[a] == '.':
					print(cnt)
					continue
				if a == 0 and a + 1 < n:
					if l[a + 1] == '.':
						cnt += 1
					l[a] = b
				elif a == n - 1 and a - 1 >= 0:
					if l[a - 1] == '.':
						cnt += 1
					l[a] = b
				elif a - 1 >= 0 and a + 1 < n:
					if l[a - 1] == '.':
						cnt += 1
					if l[a + 1] == '.':
						cnt += 1
					l[a] = b
			print(cnt)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
from heapq import heapify, heappop, heappush
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, m) = aj()
s = ['$'] + [*input()] + ['$']
count = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1] == '.':
		count += 1
for i in range(m):
	(a, b) = input().split()
	a = int(a)
	if s[a] == b == '.':
		print(count)
	elif s[a] != '.' and b != '.':
		print(count)
	elif s[a] == '.':
		if s[a - 1] == '.':
			count -= 1
		if s[a + 1] == '.':
			count -= 1
		print(count)
		s[a] = b
	else:
		if s[a - 1] == '.':
			count += 1
		if s[a + 1] == '.':
			count += 1
		print(count)
		s[a] = b


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, M) = getInts()
	S = listStr()
	dots = 0
	intervals = 0
	curr = 0
	for i in range(N):
		if S[i] == '.':
			curr += 1
			dots += 1
		elif curr > 0:
			intervals += 1
			curr = 0
	if curr > 0:
		intervals += 1
	for m in range(M):
		(idx, char) = getStrs()
		idx = int(idx) - 1
		if char == '.':
			if S[idx] == '.':
				S[idx] = char
			else:
				dots += 1
				neighbours = 0
				if idx > 0 and S[idx - 1] == '.':
					neighbours += 1
				if idx < N - 1 and S[idx + 1] == '.':
					neighbours += 1
				intervals -= neighbours - 1
				S[idx] = char
		elif S[idx] != '.':
			S[idx] = char
		else:
			dots -= 1
			neighbours = 0
			if idx > 0 and S[idx - 1] == '.':
				neighbours += 1
			if idx < N - 1 and S[idx + 1] == '.':
				neighbours += 1
			intervals += neighbours - 1
			S[idx] = char
		print(dots - intervals)
	return
solve()


from sys import stdin, stdout
input = stdin.readline
(n, m) = list(map(int, input().split()))
s = list(input())
f = 0
ans = []
i = 1
while i < n:
	if s[i] == '.' and s[i - 1] == '.':
		f += 1
	i += 1
for _ in range(m):
	change = input().split()
	(x, ch) = (int(change[0]) - 1, change[1])
	if s[x] != ch and (s[x] == '.' or ch == '.'):
		if x == 0:
			if ch == '.':
				if s[x + 1] == '.':
					f += 1
			elif s[x + 1] == '.':
				f -= 1
		elif x == len(s) - 1:
			if ch == '.':
				if s[x - 1] == '.':
					f += 1
			elif s[x - 1] == '.':
				f -= 1
		elif ch == '.':
			if s[x - 1] == s[x + 1] == '.':
				f += 2
			elif s[x - 1] != '.' and s[x + 1] == '.' or (s[x - 1] == '.' and s[x + 1] != '.'):
				f += 1
		elif s[x - 1] == s[x + 1] == '.':
			f -= 2
		elif s[x - 1] != '.' and s[x + 1] == '.' or (s[x - 1] == '.' and s[x + 1] != '.'):
			f -= 1
		s[x] = ch
	ans.append(f)
stdout.write('\n'.join(map(str, ans)))


import sys
(n, m) = map(int, sys.stdin.readline().split())
s = list(sys.stdin.readline())
queries = iter(sys.stdin.read().split())
queries = zip(queries, queries)
cnt = 0
for i in range(n - 1):
	if s[i] == '.' == s[i + 1] == '.':
		cnt += 1
for (x, c) in queries:
	x = int(x) - 1
	if c == '.':
		if s[x] != '.':
			s[x] = c
			if x - 1 >= 0 and s[x - 1] == '.':
				cnt += 1
			if x + 1 < n and s[x + 1] == '.':
				cnt += 1
	elif s[x] == '.':
		s[x] = c
		if x - 1 >= 0 and s[x - 1] == '.':
			cnt -= 1
		if x + 1 < n and s[x + 1] == '.':
			cnt -= 1
	print(cnt)


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
s = list(input())
f = 0
ans = []
for i in range(1, n):
	if s[i] == s[i - 1] and s[i] == '.':
		f += 1
for i in range(m):
	(x, ch) = input().split()
	x = int(x) - 1
	if s[x] != ch and (s[x] == '.' or ch == '.'):
		if ch == '.':
			if x > 0 and s[x - 1] == '.':
				f += 1
			if x < n - 1 and s[x + 1] == '.':
				f += 1
		else:
			if x > 0 and s[x - 1] == '.':
				f -= 1
			if x < n - 1 and s[x + 1] == '.':
				f -= 1
		s[x] = ch
	ans.append(f)
stdout.write('\n'.join(map(str, ans)))


(n, m) = map(int, input().split())
s = [j for j in input()]
cnt = 0
for i in range(1, len(s)):
	if s[i] == '.' and s[i - 1] == '.':
		cnt += 1
out = []
for _ in range(m):
	(i, c) = input().split()
	i = int(i) - 1
	if (s[i] == '.') != (c == '.'):
		if i - 1 > -1 and s[i - 1] == '.':
			if c == '.':
				cnt += 1
			else:
				cnt -= 1
		if i + 1 < len(s) and s[i + 1] == '.':
			if c == '.':
				cnt += 1
			else:
				cnt -= 1
	s[i] = c
	out.append(str(cnt))
	out.append('\n')
print(''.join(out))


import sys
(n, m) = map(int, sys.stdin.readline().split())
s = input()
left = 0
right = 0
ans = 0
while True:
	left = s.find('.', right)
	if left < 0:
		break
	right = left + 1
	while right < n and s[right] == '.':
		right += 1
	if right - left > 1:
		ans += right - left - 1
l = list(s)
ans_list = []
for i in range(m):
	query = list(sys.stdin.readline().split())
	xi = int(query[0]) - 1
	ci = query[1]
	if ci == '.' and l[xi] == '.' or (ci != '.' and l[xi] != '.'):
		pass
	elif ci == '.' and l[xi] != '.':
		if xi > 0 and l[xi - 1] == '.':
			ans += 1
		if xi < n - 1 and l[xi + 1] == '.':
			ans += 1
	elif ci != '.' and l[xi] == '.':
		if xi > 0 and l[xi - 1] == '.':
			ans -= 1
		if xi < n - 1 and l[xi + 1] == '.':
			ans -= 1
	ans_list.append(ans)
	l[xi] = ci
print('\n'.join(map(str, ans_list)))


import sys
input = sys.stdin.readline

def segtree(i, a, tree, l, r):
	if l == r:
		tree[i] = a[l]
		return tree[i]
	m = (l + r) // 2
	tree[i] = segtree(2 * i + 1, a, tree, l, m) + segtree(2 * i + 2, a, tree, m + 1, r)
	return tree[i]

def update(i, a, tree, l, r, ind):
	if ind < l or ind > r:
		return
	elif l == r:
		tree[i] = a[l]
		return
	m = (l + r) // 2
	update(2 * i + 1, a, tree, l, m, ind)
	update(2 * i + 2, a, tree, m + 1, r, ind)
	tree[i] = tree[2 * i + 1] + tree[2 * i + 2]
(n, m) = map(int, input().split())
s = list(input())
a = [0] * n
for i in range(1, n):
	if s[i] == '.' and s[i - 1] == '.':
		a[i] = 1
i = 0
while 2 ** i <= n:
	i = i + 1
tree = [0] * (2 ** (i + 1) - 1)
segtree(0, a, tree, 0, n - 1)
for _ in range(m):
	(i, c) = input().split()
	i = int(i) - 1
	if c == '.':
		if s[i] != '.':
			if i > 0:
				if s[i - 1] == '.':
					a[i] = 1
					update(0, a, tree, 0, n - 1, i)
			if i + 1 < n:
				if s[i + 1] == '.' and a[i + 1] == 0:
					a[i + 1] = 1
					update(0, a, tree, 0, n - 1, i + 1)
	elif s[i] == '.':
		a[i] = 0
		update(0, a, tree, 0, n - 1, i)
		if i + 1 < n and a[i + 1] == 1:
			a[i + 1] = 0
			update(0, a, tree, 0, n - 1, i + 1)
	s[i] = c
	sys.stdout.write(str(tree[0]) + '\n')


import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))

def main():
	(n, q) = lst()
	s = list(input())
	ans = c = 0
	for i in range(n):
		if s[i] == '.':
			c += 1
		else:
			ans += max(0, c - 1)
			c = 0
	ans += max(0, c - 1)
	for qq in range(q):
		(pos, ch) = input().split()
		pos = int(pos) - 1
		if s[pos] == '.' and ch != '.' and ((pos - 1 >= 0 and s[pos - 1] == '.') and (pos + 1 < n and s[pos + 1] == '.')):
			ans -= 2
		elif s[pos] != '.' and ch == '.' and ((pos - 1 >= 0 and s[pos - 1] == '.') and (pos + 1 < n and s[pos + 1] == '.')):
			ans += 2
		elif s[pos] == '.' and ch != '.' and (pos - 1 >= 0 and s[pos - 1] == '.'):
			ans -= 1
		elif s[pos] == '.' and ch != '.' and (pos + 1 < n and s[pos + 1] == '.'):
			ans -= 1
		elif s[pos] != '.' and ch == '.' and (pos - 1 >= 0 and s[pos - 1] == '.'):
			ans += 1
		elif s[pos] != '.' and ch == '.' and (pos + 1 < n and s[pos + 1] == '.'):
			ans += 1
		s[pos] = ch
		sys.stdout.write(str(ans) + '\n')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(1):
	main()


(n, m) = map(int, input().split())
s = [c != '.' for c in input()] + [1]
k = sum((s[i] == s[i + 1] == 0 for i in range(n - 1)))
t = [0] * m
for i in range(m):
	(x, c) = input().split()
	(x, c) = (int(x) - 1, c != '.')
	if not s[x]:
		if c:
			k += s[x - 1] + s[x + 1] - 2
	elif not c:
		k += 2 - s[x - 1] - s[x + 1]
	s[x] = c
	t[i] = k
print('\n'.join(map(str, t)))


from sys import *
inp = lambda : stdin.readline()

def main():
	(n, m) = map(int, inp().split())
	s = list(inp()[:-1])
	ans = 0
	local = 0
	for i in s:
		if i != '.':
			ans += max(0, local - 1)
			local = 0
		else:
			local += 1
	ans += max(0, local - 1)
	for i in range(m):
		(x, c) = inp().split()
		x = int(x) - 1
		if c != '.' and s[x] == '.':
			if x + 1 < n and s[x + 1] == '.':
				ans -= 1
			if x - 1 > -1 and s[x - 1] == '.':
				ans -= 1
		elif c == '.' and s[x] != '.':
			if x + 1 < n and s[x + 1] == '.':
				ans += 1
			if x - 1 > -1 and s[x - 1] == '.':
				ans += 1
		s[x] = c
		print(ans)
main()


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
s = list(input())
(k, res) = (0, [])
for i in range(n - 1):
	if s[i] == s[i + 1] == '.':
		k += 1
qrs = list((input().split() for _ in range(m)))
for i in range(m):
	(x, y) = qrs[i]
	x = int(x) - 1
	if s[x] == '.':
		if y != '.':
			if x > 0 and s[x - 1] == '.':
				k -= 1
			if x < n - 1 and s[x + 1] == '.':
				k -= 1
	elif y == '.':
		if x > 0 and s[x - 1] == '.':
			k += 1
		if x < n - 1 and s[x + 1] == '.':
			k += 1
	res.append(str(k))
	s[x] = y
print('\n'.join(res))


import sys

def read(line):
	return tuple(map(int, line.strip().split()))

def main():
	test = sys.stdin.readlines()
	string = list(test[1].strip())
	queries = []
	for line in test[2:]:
		(x, c) = line.strip().split()
		x = int(x) - 1
		queries.append((x, c))
	dots = groups = 0
	prev = '_'
	for c in string:
		if c == '.':
			dots += 1
			if prev != '.':
				groups += 1
		prev = c
	for (x, c) in queries:
		a = x >= 1 and string[x - 1] == '.'
		b = x + 1 < len(string) and string[x + 1] == '.'
		if string[x] == '.' and c != '.':
			dots -= 1
			if a and b:
				groups += 1
			elif not a and (not b):
				groups -= 1
		elif string[x] != '.' and c == '.':
			dots += 1
			if a and b:
				groups -= 1
			elif not a and (not b):
				groups += 1
		string[x] = c
		print(dots - groups)
main()


(n, m) = map(int, input().split())
s = list('a' + input() + 'a')
cnt = 0
tmp = 0
for i in range(1, n + 1):
	if s[i] == '.':
		tmp += 1
	else:
		if tmp:
			cnt += tmp - 1
		tmp = 0
if tmp:
	cnt += tmp - 1
ans = []
for i in range(m):
	(idx, ch) = input().split()
	idx = int(idx)
	if not (s[idx] == '.') ^ (ch == '.'):
		s[idx] = ch
		ans.append(cnt)
	else:
		s[idx] = ch
		mul = 1 if ch == '.' else -1
		if s[idx - 1] == '.' and s[idx + 1] == '.':
			cnt += mul * 2
		elif (s[idx - 1] == '.') ^ (s[idx + 1] == '.'):
			cnt += mul
		else:
			pass
		ans.append(cnt)
print(*ans, sep='\n')


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
s = list(((0, 1)[c == '.'] for c in list(input())))
res = 0
cnt = 0
for k in s:
	if k == 1:
		cnt += 1
	else:
		res += max(cnt - 1, 0)
		cnt = 0
res += max(0, cnt - 1)
res_list = list()
for i in range(m):
	(x, c) = input().split()
	x = int(x)
	nc = (0, 1)[c == '.']
	if s[x - 1] != nc:
		diff = 0
		if x < n:
			if s[int(x)] == 1:
				diff += 1
		if x > 1:
			if s[int(x - 2)] == 1:
				diff += 1
		if nc == 1:
			res += diff
		else:
			res -= diff
	s[x - 1] = nc
	res_list.append(res)
print(*res_list, sep='\n', flush=True)


(n, m) = map(int, input().split())
s = list(input())
ans = 0
l = []
for i in range(1, n):
	if s[i] + s[i - 1] == '..':
		ans += 1
for i in range(m):
	(a, b) = input().split()
	a = int(a) - 1
	if a > 0 and s[a - 1] + s[a] == '..':
		ans -= 1
	if a + 1 < n and s[a + 1] + s[a] == '..':
		ans -= 1
	s[a] = b
	if a > 0 and s[a - 1] + s[a] == '..':
		ans += 1
	if a + 1 < n and s[a + 1] + s[a] == '..':
		ans += 1
	l.append(str(ans))
print(' '.join(l))


from sys import stdin, stdout

def R():
	return map(int, input().split())

def F(str):
	ans = 0
	i = 0
	length = len(str)
	while i < length:
		i += 1
		if str[i - 1] == '.':
			while i < length and str[i] == '.':
				ans += 1
				i += 1
	return ans

def PountsAmount(str, ind):
	try:
		return (ind > 0 and str[ind - 1] == '.') + (ind < len(str) - 1 and str[ind + 1] == '.')
	except:
		print(str, ind)
(n, m) = R()
str = list(input())
cur = F(str)
res_list = list()
for i in range(m):
	(a, b) = input().split()
	a = int(a) - 1
	pounts_amount = PountsAmount(str, a)
	if b == '.' and str[a] != '.':
		cur += pounts_amount
	if b != '.' and str[a] == '.':
		cur -= pounts_amount
	str[a] = b
	res_list.append(cur.__str__())
stdout.write('\n'.join(res_list))


import sys
input = sys.stdin.readline
print = sys.stdout.write
(n, m) = map(int, input().split())
s = list(input())
fs = sum((a == b == '.' for (a, b) in zip(s, s[1:])))
for i in range(m):
	(x, c) = input().split()
	x = int(x) - 1
	if s[x] != '.':
		if c == '.':
			if x != 0 and s[x - 1] == '.':
				fs += 1
			if x != n - 1 and s[x + 1] == '.':
				fs += 1
	elif c != '.':
		if x != 0 and s[x - 1] == '.':
			fs -= 1
		if x != n - 1 and s[x + 1] == '.':
			fs -= 1
	s[x] = c
	print(str(fs) + '\n')


(n, m) = map(int, input().split())
s = list(input())
f = 0
ans = []
for i in range(1, n):
	if s[i] == s[i - 1] and s[i] == '.':
		f += 1
for i in range(m):
	(x, ch) = input().split()
	x = int(x) - 1
	if s[x] != ch and (s[x] == '.' or ch == '.'):
		if ch == '.':
			if x > 0 and s[x - 1] == '.':
				f += 1
			if x < n - 1 and s[x + 1] == '.':
				f += 1
		else:
			if x > 0 and s[x - 1] == '.':
				f -= 1
			if x < n - 1 and s[x + 1] == '.':
				f -= 1
		s[x] = ch
	ans.append(f)
print('\n'.join(map(str, ans)))


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
s = list(stdin.readline())
dots = 0
groups = 0
prev = 'x'
for l in s:
	if l == '.':
		dots += 1
		if prev != '.':
			groups += 1
	prev = l
lines = stdin.readlines()
for line in lines:
	(x, c) = line.split()
	x = int(x) - 1
	a = x - 1 >= 0 and s[x - 1] == '.'
	b = x + 1 < n and s[x + 1] == '.'
	if s[x] == '.' and c != '.':
		dots -= 1
		if a and b:
			groups += 1
		elif not a and (not b):
			groups -= 1
	elif s[x] != '.' and c == '.':
		dots += 1
		if a and b:
			groups -= 1
		elif not a and (not b):
			groups += 1
	s[x] = c
	stdout.write(str(dots - groups) + '\n')


def main():
	(n, m) = map(int, input().split())
	(l, res) = ([False], [])
	l.extend((c == '.' for c in input()))
	l.append(False)
	f = sum(map(all, zip(l, l[1:])))
	for _ in range(m):
		s = input()
		x = int(s[:-2])
		y = s[-1] == '.'
		if l[x] != y:
			if y:
				l[x] = True
				f += l[x - 1] + l[x + 1]
			else:
				l[x] = False
				f -= l[x - 1] + l[x + 1]
		res.append(f)
	print('\n'.join(map(str, res)))
main()