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

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)))


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)


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)


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)))


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
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')


(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)))