Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the opposite poles will attract each other.

Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own. [Image] 

Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.


-----Input-----

The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.


-----Output-----

On the single line of the output print the number of groups of magnets.


-----Examples-----
Input
6
10
10
10
01
10
10

Output
3

Input
4
01
01
10
10

Output
2



-----Note-----

The first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.

The second testcase has two groups, each consisting of two magnets.

Difficulty: EASY

Solutions:
n = int(input())
group = 1
prev = input()
for _ in range(n - 1):
	m = input()
	if m[0] == prev[1]:
		group += 1
		prev = m
print(group)


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
ans = 0
for i in range(n - 1):
	if arr[i][1] == arr[i + 1][0]:
		ans += 1
print(ans + 1)


n = input()
type(n)
n = int(n)
g = 1
magnets = []
for x in range(n):
	magnets.append(int(input()))
for x in range(len(magnets) - 1):
	if magnets[x] != magnets[x + 1]:
		g += 1
print(g)


n = int(input())
nums = []
c = 1
for i in range(0, n):
	nums.append(list(map(int, input().split())))
for i in range(n - 1):
	if nums[i] != nums[i + 1]:
		c = c + 1
print(c)


nm = int(input())
l = []
e = None
c = -1
for i in range(nm):
	if i == 0:
		e = input()
		l.append(e)
		c = c + 1
	else:
		e = input()
		if l[c] != e:
			l.append(e)
			c = c + 1
print(len(l))


n = int(input())
ans = counter = 0
for i in range(n):
	pole = input()
	if ans != pole:
		counter = counter + 1
		ans = pole
	else:
		ans = pole
print(counter)


l = []
for i in range(int(input())):
	l.append(int(input()))
c = 1
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		c += 1
print(c)


n = int(input())
j = 1
a = input()
for i in range(n - 1):
	m = input()
	if a != m:
		j += 1
		a = m
print(j)


vals = int(input())
pos = ''
for n in range(vals):
	oof = str(input())
	pos = str(pos) + oof
n = pos.count('00')
m = pos.count('11')
num = n + m + 1
print(num)


n = int(input())
a = [''] * n
c = 0
for i in range(n):
	a[i] = list(input())
for i in range(0, n - 1):
	if int(a[i][1]) != int(a[i + 1][0]):
		c += 1
print(int(len(a) - c))


n = int(input())
s = ''
for i in range(n):
	s += input()
if s.find('00') != -1:
	s = s.replace('00', 'a')
if s.find('11') != -1:
	s = s.replace('11', 'a')
c = 0
for i in range(len(s)):
	if s[i] == 'a':
		c += 1
print(int(c + 1))


n = int(input())
m = [int(input()) for i in range(n)]
s = 0
for (i, e) in enumerate(m):
	if i > 0 and m[i] != m[i - 1]:
		s += 1
print(s + 1)


a = int(input())
p = int(input())
w = p
q = 0
for i in range(1, a):
	p = w
	w = int(input())
	if p != w:
		q = q + 1
print(q + 1)


n = int(input())
a = []
for i in range(n):
	a.append(input())
c = 0
for j in range(1, len(a)):
	if a[j - 1] != a[j]:
		c += 1
print(c + 1)


n = int(input())
k = []
for i in range(n):
	m = list(map(int, input()))
	k.append(m)
s = 0
for i in range(1, len(k)):
	if k[i - 1][1] == k[i][0]:
		s += 1
print(s + 1)


n = int(input())
count = 1
arr = [None] * n
for i in range(n):
	arr[i] = input()
	if arr[i - 1] == None:
		continue
	elif arr[i] != arr[i - 1]:
		count += 1
print(count)


n = int(input())
arr = []
for i in range(n):
	z = int(input())
	arr.append(z)
count = 0
for i in range(n - 1):
	if arr[i] != arr[i + 1]:
		count += 1
print(count + 1)


n = int(input())
group = 1
a = input()
for i in range(n - 1):
	b = input()
	if b[0] == a[1]:
		group += 1
	a = b
print(group)


n = int(input())
m = ''.join([input() for _ in range(n)])
print(m.count('11') + m.count('00') + 1)


n = int(input())
l = ''
for i in range(n):
	s = input()
	l = l + s
k1 = l.count('11')
k0 = l.count('00')
print(k1 + k0 + 1)


n = int(input())
a = []

def magnetChecker(arr):
	c = 1
	for i in range(0, n - 1):
		if a[i] != a[i + 1]:
			c += 1
	print(c)
for i in range(0, n):
	a.append(input())
magnetChecker(a)


x = int(input())
groups = 1
cg = ''
for i in range(x):
	temp = input()
	if cg == '' or temp[0] != cg[-1]:
		cg += temp
	else:
		cg = ''
		cg += temp
		groups += 1
print(groups)


x = int(input())
total = 0
for y in range(1, x + 1):
	z = int(input())
	if y > 1:
		if temp != z:
			total += 1
	else:
		total += 1
	temp = z
print(total)


s = ''
for i in range(int(input())):
	s += input()
print(s.count('00') + s.count('11') + 1)


n = int(input())
(ans, s) = (1, input())
for i in range(n - 1):
	s1 = input()
	if s1[0] == s[1]:
		ans -= -1
	s = s1
print(ans)


n = int(input())
mag = []
for i in range(n):
	mag.append(str(input()))
flag = mag[0]
(count, x) = ([1], 0)
for i in range(1, n):
	if mag[i] == flag:
		count[x] += 1
	else:
		count.append(0)
		flag = mag[i]
		x += 1
		count[x] += 1
print(len(count))


n = int(input())
s = '0 0'
p = 0
for i in range(n):
	a = input()
	if a != s:
		p += 1
		s = a
print(p)


n = int(input())
res = 1
s = input()
for i in range(n - 1):
	s1 = input()
	if ord(s[1]) == ord(s1[0]):
		res += 1
	s = s1
print(res)


n = int(input())
a = []
a.append(input())
c = 1
for i in range(1, n):
	b = input()
	if a[-1][1] == b[0]:
		c = c + 1
	a.append(b)
print(c)


n = int(input())
last = input()
c = 0
for i in range(n - 1):
	new = input()
	if new != last:
		c += 1
		last = new
print(c + 1)


a = int(input())
s = []
x = ''
for i in range(a):
	x = input()
	if i == 0:
		s.append(x)
	if s != [] and x != s[-1]:
		s.append(x)
print(len(s))


import sys
n = int(input())
count = 0
for i in range(0, n):
	if i == 0:
		line = sys.stdin.readline().rstrip()
		count += 1
	else:
		line2 = sys.stdin.readline().rstrip()
		if line != line2:
			count += 1
			line = line2
print(count)


a = int(input())
l1 = []
count = 0
for i in range(0, a, 1):
	l1.append(input())
l1.append(0)
for i in range(0, a):
	if l1[i] != l1[i + 1]:
		count += 1
print(count)


n = int(input())
p = ''
c = 1
l = []
for i in range(n):
	p = p + input()
i = 1
while i < 2 * n - 1:
	if p[i] != p[i + 1]:
		c += 1
	else:
		l.append(c)
		c = 0
	i += 2
print(len(l) + 1)


n = int(input())
o = []
for i in range(n):
	o.append(input())
j = 1
for i in range(n - 1):
	if o[i] != o[i + 1]:
		j += 1
print(j)


sum = 1
n = int(input())
inputs = []
for i in range(n):
	inputs.append(input())
curr = inputs[0]
for i in range(1, n):
	if inputs[i] != curr:
		curr = inputs[i]
		sum += 1
print(sum)


n = int(input())
m1 = input()
q = 1
for i in range(n - 1):
	m2 = input()
	if m1[1] == m2[0]:
		q += 1
	m1 = m2
print(q)


x = int(input())
c = 0
for tc in range(x):
	a = input()
	if tc == 0:
		b = a
	elif a == b:
		continue
	else:
		c += 1
		b = a
print(c + 1)


n = int(input())
s = ''
for i in range(n):
	k = input()
	s += k
groups = 1
for i in range(1, len(s)):
	if s[i] == s[i - 1]:
		groups += 1
print(groups)


n = int(input())
a = []
count = 1
for i in range(n):
	a.append(input())
	if a[i] != a[i - 1]:
		count += 1
print(count)


n = int(input())
s_i = input()
ans = 1
for i in range(1, n):
	s_j = input()
	if s_i != s_j:
		ans += 1
	s_i = s_j
print(ans)


n = int(input())
p = 0
r = 0
for i in range(n):
	q = int(input())
	if q != p:
		r += 1
	p = q
print(r)


a = []
n = int(input())
for i in range(n):
	new = input()
	if len(a) == 0 or a[-1] != new:
		a.append(new)
print(len(a))


n = int(input())
ans = 1
prev = -1
for i in range(n):
	temp = input()
	if i != 0 and temp[0] == prev:
		ans += 1
	prev = temp[1]
print(ans)


n = int(input())
l1 = []
cou = 0
for i in range(n):
	l1.append(input().split())
for i in range(n - 1):
	if l1[i] != l1[i + 1]:
		cou += 1
print(cou + 1)


n = int(input())
k = ['']
antall = 0
for i in range(0, n):
	last = k[i]
	l = input()
	k.append(l)
	if l != last:
		antall += 1
print(antall)


a = 0
count = 0
for _ in range(int(input())):
	x = int(input())
	if x != a:
		count += 1
		a = x
print(count)


def fun(ls):
	prv = ls[0]
	count = 1
	for i in ls[1:]:
		if i != prv:
			prv = i
			count += 1
	print(count)
T = int(input())
ls = []
for i in range(T):
	st = input()
	ls.append(st)
fun(ls)


n = int(input())
s = []
for i in range(n):
	s.append(input())
m = 0
for x in range(n - 1):
	if s[x] != s[x + 1]:
		m += 1
print(m + 1)


a = int(input())
s = [0] * a
std = s[0]
c = 0
for i in range(a):
	s[i] = input()
	if s[i] != std:
		c = c + 1
		std = s[i]
print(c)


n = int(input())
counter = 1
arr = []
for number in range(0, n):
	arr.append(int(input()))
for i in range(0, n - 1):
	if arr[i] != arr[i + 1]:
		arr.append(i)
		counter += 1
print(counter)


n = int(input())
ans = 1
crt = int(input())
for i in range(n - 1):
	tmp = int(input())
	if tmp != crt:
		ans += 1
		crt = tmp
print(ans)


n = int(input())
a = []
b = ''
ot = 0
for i in range(n):
	t = input()
	if t != b:
		ot += 1
	b = t
print(ot)


n = int(input())
groups = 1
prevMagnet = int(input())
for i in range(n - 1):
	a = int(input())
	if a != prevMagnet:
		groups += 1
	prevMagnet = a
print(groups)


num = int(input())
a = [int(input())]
s = 1
for i in range(1, num):
	a.append(int(input()))
	if a[i - 1] != a[i]:
		s += 1
print(s)


n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a)
s = 0
for i in range(n - 1):
	if l[i] == '10' and l[i + 1] == '01':
		s += 1
	if l[i] == '01' and l[i + 1] == '10':
		s += 1
print(s + 1)


t = int(input())
v = 1
a = []
for i in range(t):
	s = int(input())
	a.append(s)
for i in range(1, t):
	if a[i] != a[i - 1]:
		v = v + 1
print(v)


n = int(input())
count = 0
magn = []
for i in range(0, n):
	param = int(input())
	if param == 1:
		param = 0
	else:
		param = 1
	magn.append(param)
if n != 1:
	for i in range(0, n - 1):
		if magn[i] == magn[i + 1]:
			count = count + 1
		else:
			continue
	print(n - count)
else:
	print('1')


_list = [input() for _ in range(int(input()))]
print(1 + len([True for (x, y) in zip(_list, _list[1:]) if x != y]))


n = int(input())
cnt = 1
f = True
for i in range(n):
	s = input()
	if i == 0:
		t = s
		continue
	if t != s:
		cnt += 1
	t = s
print(cnt)


g = 1
p = ''
for i in range(int(input())):
	s = input()
	if i > 0:
		if p[1] == s[0]:
			g += 1
	p = s
print(g)


n = int(input())
i = 0
count = 0
y = 0
while i < n:
	x = int(input())
	if x != y:
		count += 1
	y = x
	i += 1
print(count)


n = int(input())
s = 0
count = 0
e = 0
for i in range(n):
	a = input()
	s = str(s) + str(a)
	e = s[len(s) - 4:len(s) - 2]
	if e != a:
		count += 1
print(count)


n = int(input())
pre = input()
ans = 1
for i in range(n - 1):
	cur = input()
	if cur != pre:
		ans += 1
	pre = cur
print(ans)


n = int(input())
a = []
for i in range(n):
	k = input()
	a.append(k)
k = 0
c = 1
u = []
for i in range(1, len(a)):
	if a[i] != a[i - 1]:
		c += 1
	else:
		continue
print(c)


n = int(input())
s = input()
res = 1
for i in range(n - 1):
	s2 = input()
	if s != s2:
		res += 1
	s = s2
print(res)


n = int(input())
z = 0
count = 1
new_list = []
for i in range(n):
	x = int(input())
	new_list.append(x)
for j in range(len(new_list) - 1):
	if new_list[j] != new_list[j + 1]:
		count += 1
print(count)


siz = int(input())
lst = list()
for i in range(siz):
	val = int(input())
	lst.append(val)
cnt = 1
for i in range(len(lst) - 1):
	if lst[i] != lst[i + 1]:
		cnt += 1
print(cnt)


t = int(input())
i = 0
v = 0
c = 0
while i < t:
	n = input()
	if i == 0:
		if n == '10':
			v = 0
		else:
			v = 1
	if n == '10':
		if v == 0:
			c += 1
		v = 1
	else:
		if v == 1:
			c += 1
		v = 0
	i += 1
print(c)


n = int(input())
i = 0
while i < n:
	a = input()
	if i == 0:
		b = a
		ans = 1
		i += 1
		continue
	if a == b:
		i += 1
		continue
	else:
		ans += 1
		b = a
		i += 1
print(ans)


x = int(input())
c = [1, 0, 0]
for i in range(x):
	c[2] = int(input())
	if c[2] + c[1] == 11:
		c[0] += 1
	c[1] = c[2]
print(c[0])


n = input()
n = int(n)
m = []
s = 1
for i in range(n):
	m += input().split()
	if m[i - 1] != m[i]:
		s += 1
print(s)


n = int(input())
magnets = list()
for i in range(n):
	magnets.append(input())
c = 1
prev = ''
isl = 1
for i in magnets:
	if c:
		prev = i
		c = 0
	else:
		if prev != i:
			isl += 1
		prev = i
print(isl)


n = int(input())
pares = []
nGroups = 1
for i in range(n):
	pares.append(input())
while n > 0:
	if n - 2 >= 0:
		if pares[n - 1] != pares[n - 2]:
			nGroups += 1
	n -= 1
print(nGroups)


n = int(input(''))
tot = 1
listA = []
before = ''
while n > 0:
	g = input('')
	listA.append(g)
	n -= 1
for i in range(1, len(listA)):
	if listA[i] != listA[i - 1]:
		tot += 1
	else:
		tot = tot
print(tot)


n = int(input())
s = 0
k = '0'
for i in range(n):
	m = input()
	if m != k:
		s += 1
	k = m
print(s)


n = int(input().strip())
prev = None
count = 1
for _ in range(n):
	magnet = list(input().strip())
	if prev:
		if magnet[0] == prev[-1]:
			count += 1
			prev = magnet
		else:
			prev.extend(magnet)
	else:
		prev = magnet
print(count)


a = input()
a = int(a)
b = list()
for i in range(a):
	b.append(input())
c = '0'
co = 1
for i in range(len(b) - 1):
	if b[i] != b[i + 1]:
		co += 1
print(co)


n = int(input())
ans = 1
s1 = input()
for i in range(n - 1):
	s2 = input()
	if s1 != s2:
		ans += 1
	s1 = s2
print(ans)


n = int(input())
m = []
for i in range(n):
	m.append(input())
g = 1
for i in range(1, len(m)):
	if m[i] != m[i - 1]:
		g += 1
print(g)


n = int(input())
magnets = []
for i in range(n):
	magnet = int(input())
	magnets.append(magnet)
changes = 1
for i in range(n - 1):
	if magnets[i] != magnets[i + 1]:
		changes += 1
print(changes)


n = int(input())
before = str(input())
total = 1
for i in range(1, n):
	now = str(input())
	if now == before:
		continue
	else:
		total += 1
		before = now
print(total)


s1 = int(input())
x = 0
groups = 0
checker = ''
while x < s1:
	tempo = input()
	if checker != tempo:
		checker = tempo
		groups += 1
	x += 1
print(groups)


n = int(input())
list = []
for i in range(n):
	m = int(input())
	list.append(m)
a = 1
for i in range(n - 1):
	if list[i] != list[i + 1]:
		a = a + 1
print(a)


prev = ''
groups = 0
for i in range(int(input())):
	magnet = input()
	if prev == '' or magnet != prev:
		groups += 1
	prev = magnet
print(groups)


i = input
s = ''.join((i() for _ in int(i()) * ' '))
print(1 + s.count('00') + s.count('11'))


import sys
n = int(sys.stdin.readline())
first_str = list(sys.stdin.readline())
count = 1
for i in range(1, n):
	second_str = list(sys.stdin.readline())
	if first_str[1] == second_str[0]:
		first_str = second_str
		count += 1
print(count)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	r = 0
	c = '-1'
	for _ in range(n):
		t = S()
		if c == t:
			continue
		c = t
		r += 1
	return r
print(main())


magnets = ''
for _ in range(int(input())):
	magnets += input()
print(magnets.count('00') + magnets.count('11') + 1)


import math
n = int(input())
a = []
k = 1
for i in range(n):
	a.append(str(input()))
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		k = k + 1
print(k)


n = int(input())
groups = 1
prev = int(input())
for i in range(1, n):
	new = int(input())
	if new != prev:
		groups = groups + 1
		prev = new
print(groups)


n = int(input())
q = 1
w = []
w.append(input())
for i in range(n - 1):
	w.append(input())
	if w[-2] != w[-1]:
		q += 1
print(q)


from math import ceil
import sys, bisect, copyreg, copy, statistics, os

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

def IIX():
	return (int(x) for x in sys.stdin.readline().split())

def II():
	return int(inp())

def LI():
	return list(map(int, inp().split()))

def LS():
	return list(map(str, inp().split()))

def L(x):
	return list(x)

def out(var):
	return sys.stdout.write(str(var))
n = II()
stack = []
stack.append(II())
grp = 1
for i in range(1, n):
	gg = II()
	if gg != stack[-1]:
		stack.append(gg)
		grp += 1
out(grp)


n = int(input())
prevmagnet = ''
groups = 0
while n > 0:
	magnet = input()
	if magnet != prevmagnet:
		prevmagnet = magnet
		groups += 1
	n -= 1
print(groups)


def main():
	n = int(input())
	b = input()
	cnt = 1
	for i in range(n - 1):
		a = input()
		if a != b:
			b = a
			cnt += 1
	print(cnt)
main()


n = int(input())
count = 0
prev = '00'
for _ in range(n):
	cur = input()
	if prev != cur:
		count += 1
	prev = cur
print(count)


t = int(input())
l = []
for i in range(t):
	l.append(int(input()))
c = 1
for i in range(0, t - 1):
	if l[i] == l[i + 1]:
		continue
	else:
		c = c + 1
print(c)


n = int(input())
count = 1
z = []
for i in range(n):
	z.append(input())
i = 0
while i < n - 1:
	if z[i] != z[i + 1]:
		count = count + 1
		i = i + 1
	else:
		i = i + 1
print(count)


dic = {}
(c, b) = (1, 'xx')
for i in range(int(input())):
	a = input()
	c += b[1] == a[0]
	b = a
print(c)


ls = []
count = 0
n = int(input())
for i in range(n):
	magnet = input()
	ls.append(magnet)
count = 1
first = ls[0]
for m in ls[1:]:
	if first[1] != m[0]:
		continue
	else:
		count += 1
		first = m
print(count)


n = int(input())
l = []
count = 1
for i in range(n):
	s = input()
	l.append(s)
for i in range(1, len(l)):
	if l[i - 1] != l[i]:
		count += 1
print(count)


n = int(input())
s = ''
for i in range(n):
	s = s + input()
sectors = 1
for i in range(1, 2 * n):
	if s[i - 1] == s[i]:
		sectors = sectors + 1
print(sectors)


n = int(input())
counter = 0
current = ''
for i in range(n):
	m = input()
	if current == '':
		current = m
		counter = 1
	elif current != m:
		current = m
		counter += 1
print(counter)


m = int(input())
t = []
for i in range(m):
	t.append(input())
count = 0
last = 0
for i in t:
	if i != last:
		count += 1
		last = i
print(count)


def main():
	n = int(input())
	m_prev = input()
	grp = 1
	for i in range(n - 1):
		m = input()
		if m_prev[-1] == m[0]:
			grp += 1
		m_prev = m
	print(grp)
main()


n = int(input())
count = ''
while n > 0:
	n -= 1
	count += input()
a = count.count('11')
b = count.count('00')
print(a + b + 1)


n = int(input())
count = 1
previous = None
for i in range(n):
	x = int(input())
	if previous == None:
		previous = x
	elif previous != x:
		count += 1
		previous = x
print(count)


count_magnets = int(input())
count_island = 0
order = []
s = 0
for i in range(count_magnets):
	sign = input()
	order.append(sign)
	if i > 0:
		if order[s] == order[s + 1]:
			s += 1
			continue
		else:
			count_island += 1
			s += 1
print(count_island + 1)


a = int(input())
r = 1
b = input()
c = b[0]
for i in range(a - 1):
	b = input()
	if b[0] != c:
		r += 1
		c = b[0]
print(r)


n = int(input())
g = 1
l = []
for i in range(n):
	k = int(input())
	l.append(k)
for i in range(1, n):
	if l[i] == l[i - 1]:
		pass
	else:
		g = g + 1
print(g)


n = int(input())
s = 0
piz = input()
for i in range(n - 1):
	da = input()
	if piz != da:
		s += 1
	piz = da
print(s + 1)


n = int(input())
nr = 0
prev = '-1'
for _ in range(n):
	x = input()
	if x != prev:
		nr += 1
		prev = x
print(nr)


n = int(input())
i = 0
j = 0
l = []
for i in range(n):
	n1 = int(input())
	l.append(n1 % 10)
i = i + 1
count = 1
for (i, j) in zip(l[:], l[1:]):
	if i != j:
		count = count + 1
print(count)


l = []
n = int(input())
i = 0
nb = 0
while i < n:
	x = input()
	l.append(x)
	i += 1
if n == 1:
	nb = 0
else:
	for j in range(1, n):
		if l[j] != l[j - 1]:
			nb += 1
print(nb + 1)


magnets_cnt = int(input())
islands_cnt = 1
prev_magnet = None
for i in range(magnets_cnt):
	magnet_data = list(input())
	if prev_magnet is not None:
		if prev_magnet[1] == magnet_data[0]:
			islands_cnt += 1
	prev_magnet = magnet_data
print(islands_cnt)


n = int(input())
a = input()
count = 1
for i in range(n - 1):
	b = input()
	if b == a:
		pass
	else:
		a = b
		count += 1
print(count)


n = int(input())
k = 1
list = []
for i in range(n):
	magnet = input()
	list.append(magnet)
for i in range(n - 1):
	if list[i][1] == list[i + 1][0]:
		k += 1
print(k)


def cf_344a():
	c = int(input())
	groups = 0
	prev = None
	for _ in range(c):
		m = input()
		if prev == None:
			prev = m[1]
		elif prev == m[0]:
			groups += 1
			prev = m[1]
	groups += 1
	print(groups)
cf_344a()


(list_in, cnt) = ([], 1)
for x in range(int(input().strip())):
	list_in.append(input())
if len(list_in) > 1:
	for x in range(len(list_in) - 1):
		if list_in[x][1] == list_in[x + 1][0]:
			cnt += 1
print(cnt)


n = int(input())
g = 0
last = ''
while n > 0:
	s = input().strip()
	if s != last:
		g = g + 1
		last = s
	n = n - 1
print(g)


n = int(input())
string = ''
for i in range(n):
	s = str(input())
	string = string + s
count = 0
for i in range(1, len(string) - 1):
	if string[i] == string[i + 1]:
		count = count + 1
print(count + 1)


n = int(input())
for i in range(n):
	if i == 0:
		magnet = str(input())
		group_count = 1
		continue
	previous_magnet = magnet
	magnet = str(input())
	if magnet != previous_magnet:
		group_count += 1
print(group_count)


magnets = int(input())
prev = None
groups = 0
for i in range(magnets):
	magnet = input()
	if not prev:
		groups += 1
		prev = magnet[1]
		continue
	if prev == magnet[0]:
		groups += 1
	prev = magnet[1]
print(groups)


a = ''
for i in range(int(input())):
	a = a + input()
print(a.count('11') + a.count('00') + 1)


from typing import List
from itertools import groupby
MAGNETS = List[str]

def solve(*, magnets: MAGNETS) -> int:
	return len(list(groupby(magnets)))
n = int(input())
LIMIT = n + 99
magnets = [input() for _ in range(n)]
result = solve(magnets=magnets)
print(result)


def get():
	return [int(x) for x in input().split()]
(n,) = get()
prev = None
r = 1
for _ in range(n):
	now = input()
	if prev and prev != now:
		r += 1
	prev = now
print(r)


n = int(input())
magnets = [input() for _ in range(n)]
prev = ''
count = 0
for magnet in magnets:
	if magnet != prev:
		count += 1
	prev = magnet
print(count)


cant = int(input())
m = input()
suma = 1
for a in range(cant - 1):
	n = input()
	if m != n:
		suma += 1
	m = n
print(suma)


g = 1
a = []
for i in range(int(input())):
	x = int(input())
	a.append(x)
	if len(a) > 1 and x != a[len(a) - 2]:
		g += 1
print(g)


lines = []
while True:
	try:
		lines.append(input())
	except EOFError:
		break
num_magnets = lines[0]
count = 1
scan = lines[1]
for x in range(1, int(num_magnets) + 1):
	if scan == lines[x]:
		continue
	else:
		scan = lines[x]
		count = count + 1
print(count)


d = []
for i in range(int(input())):
	d.append(input())
i = 0
c = 1
for j in range(1, len(d)):
	if d[j] != d[i]:
		c += 1
		i = j
		j += 1
print(c)


n = int(input())
arr = [input() for i in range(n)]
j = 0
s = ''.join(arr)
for k in range(1, len(s) - 1):
	if s[k] == s[k + 1]:
		j += 1
print(j + 1)


n = int(input())
prev = int(input())
a = 1
for _ in range(0, n - 1):
	pres = int(input())
	if pres != prev:
		a += 1
	prev = pres
print(a)


c = int(input())
res = 0
m = []
for i in range(c):
	newI = int(input())
	if newI not in m[-1:]:
		res += 1
	m.append(newI)
print(res)


n = int(input())
g = 1
be = input()
for i in range(1, n):
	ne = input()
	if ne[0] == be[1]:
		g += 1
	be = ne
print(g)


qtd = int(input())
anterior = '00'
grupos = 0
for _ in range(qtd):
	novo = input()
	if anterior != novo:
		grupos += 1
	anterior = novo
print(grupos)


import sys

def gl():
	return sys.stdin.readline()

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

def gls():
	return sys.stdin.readline().split()

def glm():
	return list(map(int, sys.stdin.readline().split()))
n = gli()
a = []
g = 0
for i in range(n):
	a.append(gli())
for i in range(n - 1):
	if a[i] != a[i + 1]:
		g += 1
print(g + 1)


v = [input() for i in range(int(input()))]
print(1 + sum((a != b for (a, b) in zip(v, v[1:]))))


numberOfSteps = int(input())
magnetReference = input()
magnetRow = magnetReference
for i in range(numberOfSteps - 1):
	newMagnet = input()
	if newMagnet == magnetReference:
		magnetRow += newMagnet
	else:
		magnetReference = newMagnet
		magnetRow += ' ' + newMagnet
print(len(magnetRow.split()))


n = int(input())
s = ''
while n:
	t = input()
	s += t
	n -= 1
print(s.count('00') + s.count('11') + 1)


n = int(input())
data = [input() for i in range(n)]
groups = 1
for j in range(len(data) - 1):
	if data[j] != data[j + 1]:
		groups += 1
print(groups)


def Main():
	n = int(input())
	prev = input()
	ans = 1
	for _ in range(n - 1):
		curr = input()
		if prev[1] == curr[0]:
			ans += 1
		prev = curr
	print(ans)
Main()


n = int(input())
groupCount = 1
lastTail = input()[1]
for _ in range(n - 1):
	m = input()
	if lastTail == m[0]:
		groupCount += 1
		lastTail = m[1]
print(groupCount)


n = int(input())
magnets = []
for item in range(n):
	magnets.append(input())
n_rows = 1
for item in range(1, n):
	if magnets[item] != magnets[item - 1]:
		n_rows += 1
print(n_rows)


n = int(input())
b = input()
k = 1
for i in range(n - 1):
	a = input()
	if a != b:
		k += 1
		b = a
print(k)


counter = int(input())
magnets = ''
for i in range(counter):
	magnets += input()
print(magnets.count('11') + magnets.count('00') + 1)


n = int(input())
l = []
ans = 1
for i in range(n):
	if i == 0:
		l.append(int(input()))
		continue
	else:
		l.append(int(input()))
		if l[i] != l[i - 1]:
			ans += 1
print(ans)


n = int(input())
magnet = []
for i in range(n):
	magnet.append(str(input()))
island = 1
temp = magnet[0][1]
for i in range(1, n):
	if temp != magnet[i][1]:
		island += 1
		temp = magnet[i][1]
print(island)


size = int(input())
total = 1
current = input()
for v in range(size - 1):
	value = input()
	if value != current:
		current = value
		total += 1
print(total)


a = int(input())
l = []
for i in range(a):
	b = input()
	l.append(b)
m = []
for i in range(1, a):
	if l[i - 1] == l[i]:
		m.append(0)
	else:
		m.append(1)
print(int(sum(m)) + 1)


c = 0
n = int(input())
t = '2'
for i in range(n):
	m = input()
	if m[0] != t:
		c += 1
		t = m[0]
print(c)


n = int(input())
magnets = []
group = ['']
for i in range(n):
	ai = input()
	magnets.append(ai)
for magnet in magnets:
	if magnet != group[-1]:
		group.append(magnet)
	else:
		continue
print(len(group) - 1)


n = int(input())
s = 2
r = 0
for i in range(n):
	a = int(input())
	if s != a:
		r += 1
	s = a
print(r)


import sys
t = int(input()) - 1
last = sys.stdin.readline()
iland = 1
for _ in range(t):
	new = sys.stdin.readline()
	if last != new:
		iland += 1
		last = new
print(iland)


n = int(input())
l = []
num = 1
for i in range(n):
	l.append(input())
for i in range(1, n):
	if l[i] != l[i - 1]:
		num += 1
print(num)


def groups(l):
	c = l[0]
	numGroups = 1
	for i in l[1:]:
		if i != c:
			c = i
			numGroups += 1
	print(numGroups)
n = int(input())
ip = []
for i in range(n):
	ip.append(input())
groups(ip)


n = int(input())
t = '00'
groups = 0
for i in range(n):
	s = input()
	if s != t:
		groups += 1
		t = s
print(groups)


number_of_magnets = int(input())
if number_of_magnets == 1:
	print(1)
else:
	n_of_pairs = 1
	last_magnet = input()
	for i in range(number_of_magnets - 1):
		magnet = input()
		if magnet != last_magnet:
			n_of_pairs += 1
		last_magnet = magnet
	print(n_of_pairs)


n = int(input())
nd = r = 0
for i in range(0, n):
	k = int(input())
	if k != r:
		nd += 1
	r = k
print(nd)


n = int(input())
g = n
old_i = input()
for _ in range(n - 1):
	i = input()
	if i[0] != old_i[1]:
		g -= 1
	old_i = i
print(g)


from itertools import groupby
a = int(input())
b = (input() for i in range(a))
l = list(groupby(b))
print(len(l))


t = int(input())
ans = 1
p = input()
for o in range(1, t):
	x = input()
	if x != p:
		ans = ans + 1
	p = x
print(ans)


l = []
s = 1
for x in range(int(input())):
	i = input()
	l.append(i)
for x in range(len(l) - 1):
	if l[x] != l[x + 1]:
		s = s + 1
print(s)


counter = 1
lyst = []
x = int(input())
for i in range(x):
	y = int(input())
	lyst.append(y)
for j in range(len(lyst) - 1):
	if lyst[j] != lyst[j + 1]:
		counter += 1
print(counter)


def main():
	n = int(input())
	lst = []
	for it in range(n):
		m = input()
		lst.append(m)
	g = 1
	for it in range(1, n):
		if lst[it] == lst[it - 1]:
			continue
		else:
			g = g + 1
	print(g)
main()


temp = ''
n = int(input())
for e in range(n):
	temp += input()
magnets_couter = 0
for i in range(1, len(temp), 2):
	if i + 1 < len(temp) and temp[i] == temp[i + 1]:
		magnets_couter += 1
print(magnets_couter + 1)


n = int(input())
ans = 1
x = []
for i in range(n):
	x += [input()]
for i in range(1, n):
	if x[i] != x[i - 1]:
		ans += 1
print(ans)


n = int(input())
c = 1
now = input()
for i in range(n - 1):
	this = input()
	if this != now:
		c += 1
		now = this
print(c)


n = int(input())
pre = int(input())
counter = 1
for i in range(n - 1):
	curr = int(input())
	if curr != pre:
		counter += 1
	pre = curr
print(counter)


groups = 1
n = int(input())
a = input()
for _ in range(n - 1):
	b = input()
	if a != b:
		groups += 1
	a = b
print(groups)


from itertools import tee
n = int(input())
(i, j) = tee((input() for _ in range(n)))
next(i)
print(sum((a != b for (a, b) in zip(i, j))) + 1)


n = int(input())
l = list()
z = input()
l.append(z)
c = 1
for i in range(1, n):
	a = input()
	if a != l[i - 1]:
		c += 1
	l.append(a)
print(c)


t = int(input())
c = 1
ar = [0] * t
for i in range(0, t):
	ar[i] = input()
for i in range(0, t - 1):
	if ar[i] != ar[i + 1] and (ar[i] == '10' or ar[i] == '01') and (ar[i + 1] == '10' or ar[i + 1] == '01'):
		c = c + 1
print(c)


n = int(input(''))
magnets = []
group = n
for i in range(0, n):
	s = input('')
	magnets.append(s)
mag = magnets[0]
for i in range(1, len(magnets)):
	if magnets[i] == mag:
		group -= 1
	mag = magnets[i]
print(group)


n = int(input())
arr = []
l = 0
for i in range(n):
	f = input()
	arr.append(f)
for i in range(len(arr) - 1):
	if arr[i][1] == arr[i + 1][0]:
		l += 1
print(l + 1)


n = int(input())
s = '00'
prev = ''
ans = 0
i = 0
while i < n:
	b = input()
	if b != prev:
		ans += 1
		prev = b
	i += 1
print(ans)


n = int(input())
t = []
for i in range(n):
	t.append(input())
nb = 1
x = t[0]
for i in t:
	if i != x:
		nb = nb + 1
		x = i
print(nb)


n = int(input())
y = []
for i in range(n):
	y.append(int(input()))
ctr = 1
for i in range(0, n - 1):
	if y[i] != y[i + 1]:
		ctr += 1
print(ctr)


def main():
	n = int(input())
	a = []
	a.append(input())
	islands = 1
	for _ in range(n - 1):
		a.append(input())
		if a[-2][1] == a[-1][0]:
			islands += 1
	print(islands)
main()


s = ''
c = 0
for i in range(int(input())):
	s1 = input()
	if s != s1:
		c = c + 1
	s = s1
print(c)


n = int(input())
(prev, res) = ('', 0)
for _ in range(n):
	cur = input()
	if cur != prev:
		res += 1
		prev = cur
print(res)


n = int(input())
s = [' ' for i in range(100001)]
for i in range(n):
	x = input()
	s[i] = x
i = 0
m = 1
while i < n - 1:
	if s[i][1] == s[i + 1][0]:
		m += 1
	i += 1
print(m)


import sys

def function1(n, s):
	k = 1
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			k += 1
	return k

def main():
	n = int(input())
	s = sys.stdin.readlines()
	print(function1(n, s))
main()


n = int(input())
count = 1
f = int(input())
for i in range(n - 1):
	x = int(input())
	if x != f:
		count += 1
		f = x
print(count)


n = int(input())
old = 0
ans = 0
for i in range(n):
	now = int(input())
	if now != old:
		ans += 1
	old = now
print(ans)


n = int(input())
islands = 0
prev = ''
current = ''
for i in range(n):
	current = input()
	if i == 0:
		islands += 1
	elif prev != current:
		islands += 1
	prev = current
print(islands)


a = int(input())
x = []
x.append(input())
i = 1
for n in range(a - 1):
	t = input()
	if t != x[i - 1]:
		x.append(t)
		i += 1
print(len(x))


n = int(input())
groups = 1
pole = list(input())
last_pole = pole[1]
for i in range(n - 1):
	pole = list(input())
	if pole[0] == last_pole:
		groups += 1
	last_pole = pole[1]
print(groups)


import itertools
n = int(input())
magnets = []
for i in range(n):
	magnets.append(int(input()))
print(len(list(itertools.groupby(magnets))))


n = int(input())
c = 1
x = input()
for i in range(1, n):
	s = input()
	if s == x:
		continue
	else:
		c += 1
	x = s
print(c)


n = int(input())
group = 0
e = '00'
for i in range(0, n):
	p = input()
	if p != e:
		group = group + 1
	e = p
print(group)


magnets = 1
n = int(input())
x = input()
y = str()
for i in range(n - 1):
	y = input()
	if x != y:
		magnets += 1
	x = y
print(magnets)


n = int(input())
s = []
count = 0
for i in range(n):
	s.append(input())
for i in range(n - 1):
	if s[i] != s[i + 1]:
		count += 1
print(count + 1)


n = int(input())
a = '0'
count = 0
for i in range(0, n):
	x = input()
	if x != a:
		count += 1
	a = x
print(count)


n = int(input())
line = []
count = 0
for i in range(n):
	line.append(input())
line_str = ''.join(line)
for j in range(2 * n - 1):
	if line_str[j] == line_str[j + 1]:
		count += 1
print(count + 1)


n = int(input())
mas = [int(input()) for _ in range(n)]
a = 0
for i in range(n - 1):
	if mas[i] != mas[i + 1]:
		a += 1
print(a + 1)


t = int(input())
a = ''
count = 0
for i in range(t):
	b = input()
	if a != b:
		a = b
		count += 1
print(count)


n = int(input())
groups = 1
lst = []
for i in range(0, n):
	inp = int(input())
	lst.append(inp)
for j in range(0, n - 1):
	if lst[j] != lst[j + 1]:
		groups += 1
print(groups)


n = int(input())
prev = ''
counter = 0
for i in range(n):
	s = input()[1]
	if prev == '' or prev != s:
		counter += 1
	prev = s
print(counter)


number = input()
lines = []
ans = 1
for i in range(int(number)):
	line = input()
	lines.append(line)
for every in range(1, int(number)):
	if lines[every] != lines[every - 1]:
		ans += 1
print(ans)


count = int(input())
cur = ''
prev = input()
res = 1
for item in range(count - 1):
	cur = input()
	if cur != prev:
		res += 1
		prev = cur
print(res)


numbers = int(input())
i = 0
blocks = 0
switch = 0
while i < numbers:
	index = int(input())
	if index != switch:
		blocks += 1
	switch = index
	i += 1
print(blocks)


n = int(input())
a = [0 for i in range(n)]
counter = 1
for i in range(n):
	a[i] = int(input())
for i in range(1, n):
	if a[i] != a[i - 1]:
		counter += 1
print(counter)


n = int(input())
groups = 0
res = ''
for i in range(n):
	s = input()[:2]
	if res == '':
		res += s
		groups += 1
	elif s[0] == res[len(res) - 1]:
		groups += 1
		res = s
	else:
		res += s
print(groups)


x = int(input(''))
y = input('')
group = 1
for i in range(x - 1):
	curr = input('')
	if curr != y:
		group += 1
		y = curr
print(group)


n = int(input())
prev = count = 0
for i in ' ' * n:
	x = input()
	count += x != prev
	prev = x
print(count)


def func():
	n = int(input())
	c = 0
	prev = int(input())
	while n != 1:
		t = int(input())
		if t != prev:
			c = c + 1
			prev = t
		n = n - 1
	print(c + 1)
func()


while True:
	try:
		n = int(input())
		magnets = []
		previous_signal = '*'
		groups_counter = 1
		for i in range(n):
			magnet = input()
			current_leftmost = magnet[0]
			if current_leftmost == previous_signal:
				groups_counter += 1
			previous_signal = magnet[1]
		print(groups_counter)
	except EOFError:
		break


n = int(input())
(i, z, y) = (0, 0, '')
while i < n:
	x = input()
	z += 1 if x != y else 0
	y = x
	i += 1
print(z)


import sys
import math
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
gp = 1
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		gp += 1
print(gp)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt

def binNumber(n, size=1):
	return bin(n)[2:].zfill(size)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

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

def ini():
	return int(input())

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

def sti():
	return str(input())
n = ini()
p = ''
k = 1
for i in range(n):
	s = sti()
	if i == 0:
		p = s
		continue
	elif s != p:
		k += 1
		p = s
print(k)


n = int(input())
cnt = 1
l = input()
for i in range(1, n):
	s = input()
	if s[0] != l[-1]:
		l += s
	else:
		l = s
		cnt += 1
print(cnt)


n = int(input())
cnt = 0
for i in range(n):
	k = int(input())
	if i == 0:
		cnt += 1
	elif k == prev:
		continue
	else:
		cnt += 1
	prev = k
print(cnt)


x = int(input())
y = []
for n in range(x):
	a = int(input())
	y.append(a)
k = 0
for e in range(x - 1):
	if y[e] == y[e + 1]:
		k = k
	else:
		k = k + 1
print(k + 1)


import math
n = int(input())
last = '2'
count = 1
for i in range(n):
	data = input()
	if i == 0:
		last = data[1]
		continue
	if data[0] == last:
		count += 1
	last = data[1]
print(count)


n = int(input())
ans = 1
cur = -1
row = ''
for _ in range(n):
	row += input()
for x in range(len(row) - 1):
	if row[x] == row[x + 1]:
		ans += 1
print(ans)


n = int(input())
last = int(input())
result = 1
for i in range(1, n):
	next = int(input())
	if next != last:
		result += 1
	last = next
print(result)


n = int(input())
cnt = 1
last = None
for _ in range(n):
	x = int(input())
	if last is None:
		last = x
	if last != x:
		cnt += 1
	last = x
print(cnt)


(n, islands, last) = (int(input()), 1, input()[0])
for i in range(1, n):
	magnet = input()
	if last != magnet[0]:
		islands += 1
		last = magnet[0]
print(islands)


n = int(input())
arr1 = []
flag1 = 0
flag2 = 0
count = 0
for i in range(0, n):
	arr = input()
	if arr[0] == '1':
		flag1 = 1
	elif flag1 == 1 and arr[0] == '0':
		count += 1
		flag2 = 1
		flag1 = 0
	if arr[0] == '0':
		flag2 = 1
	elif flag2 == 1 and arr[0] == '1':
		count += 1
		flag1 = 1
		flag2 = 0
print(count + 1)


import math
n = int(input())
l = []
c = 0
for i in range(n):
	p = int(input())
	l.append(p)
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		c = c + 1
print(c + 1)


lst = []
cnt = 1
for i in range(int(input())):
	lst.append(input())
n = len(lst)
for i in range(1, n):
	if lst[i][1] == lst[i - 1][0]:
		cnt += 1
print(cnt)


n = int(input())
domino = []
islands = 1
for i in range(n):
	domino.append(input())
for i in range(1, n):
	if domino[i] != domino[i - 1]:
		islands += 1
print(islands)


n = int(input())
last = '22'
res = 0
for i in range(n):
	s = input()
	if s != last:
		res = res + 1
	last = s
print(res)


n = int(input())
nd = 1
a = None
for i in range(0, n):
	if i == 0:
		a = input()
	else:
		s = input()
		if a == s:
			pass
		else:
			nd += 1
			a = s
print(nd)


x = int(input())
ctr = 1
a = 0
b = 0
for i in range(x):
	b = input()
	if a != b and i > 0:
		ctr += 1
	a = b
print(ctr)


n = int(input())
groups = 1
magnets = []
while n > 0:
	magnets.append(input())
	n -= 1
for i in range(1, len(magnets)):
	if magnets[i][0] == magnets[i - 1][1]:
		groups += 1
print(groups)


count = 0
prev = ''
for i in range(int(input())):
	curr = input()
	if curr != prev:
		count += 1
		prev = curr
print(count)


def solve():
	n = int(input())
	groups = 1
	tracker = list(input())[1]
	for j in range(n - 1):
		try:
			i = list(input())
			if i[0] == tracker:
				groups += 1
			tracker = i[1]
		except Exception as e:
			print(e)
	return groups
print(solve())


n = int(input())
t = 1
a = input()
for i in range(1, n):
	s = input()
	if a != s:
		t += 1
	a = s
print(t)


(t, r) = (0, 0)
for i in range(int(input())):
	p = input()
	if t == 0:
		t = p
	elif t != p:
		r += 1
		t = p
print(r + 1)


n = int(input())
count = 0
mag_previos = '00'
for i in range(n):
	mag = input()
	if mag != mag_previos:
		count += 1
	mag_previos = mag
print(count)


ans = 1
prev = 0
for i in range(int(input())):
	s = input()
	if i == 0:
		prev = s[-1]
	else:
		if s[0] == prev:
			ans += 1
		prev = s[-1]
print(ans)


n = int(input())
num_of_groups = 1
magnets = []
for i in range(n):
	magnets.append(input())
magnets = ''.join(map(str, magnets))
for i in range(2, len(magnets), 2):
	if magnets[i] == magnets[i - 1]:
		num_of_groups += 1
print(num_of_groups)


import sys
n = int(sys.stdin.readline())

def findIslands(n):
	Islands = 1
	last = sys.stdin.readline().strip()
	for req in range(n - 1):
		magnet = sys.stdin.readline().strip()
		if last != magnet:
			Islands += 1
		last = magnet
	return Islands
print(findIslands(n))


n = int(input())
last = None
groups = 0
for i in range(n):
	now = input()
	if now != last:
		groups += 1
	last = now
print(groups)


import sys, random, math
i = int(input())
stri = ''
count = 0
for n in range(i):
	new = input()
	if new != stri:
		count = count + 1
		stri = new
print(str(count))


n = int(input())
l = []
for i in range(n):
	s = int(input())
	l.append(s)
c = 0
for k in range(len(l) - 1):
	if l[k] != l[k + 1]:
		c = c + 1
print(c + 1)


n = int(input())
str1 = ''
for i in range(n):
	str1 += input()
L = list(str1)
groups = 1
x = len(L)
for i in range(x - 1):
	if L[i] == L[i + 1]:
		groups += 1
print(groups)


n = int(input())
m = input()
atract = True
group = 1
for i in range(n - 1):
	p = m
	m = input()
	if p[1] == m[0]:
		atract = True
	else:
		atract = False
	if atract:
		group = group + 1
print(group)


n = int(input())
l = []
c = 0
for _ in range(n):
	l.append(input())
for i in range(n - 1):
	if l[i][1] == l[i + 1][0]:
		c += 1
print(c + 1)


n = int(input())
p = '22'
c = 0
for i in range(n):
	a = input()
	if p[-1] == a[0]:
		c += 1
	p = a
print(c + 1)


n = int(input())
res = 1
a = []
for i in range(n):
	s = int(input())
	a.append(s)
	if a[i] != a[i - 1]:
		res += 1
print(res)


n = int(input())
l = []
c = 1
for i in range(n):
	e = int(input())
	l.append(e)
for x in range(n - 1):
	if n > 1:
		if l[x] != l[x + 1]:
			c += 1
			continue
	else:
		print('1')
		exit()
print(c)


n = int(input())
c = 0
b = []
for h in range(n):
	m = input()
	if b == []:
		b.append(m)
	elif b[len(b) - 1][1] != m[0]:
		b.append(m)
	else:
		c += 1
		b = []
		b.append(m)
print(c + 1)


n = int(input())
s = []
f = '0'
grp = 1
for i in range(n):
	a = input()
	if a != f and f != '0':
		grp += 1
	f = a
print(grp)


n = int(input())
s = ''
for i in range(n):
	temp = str(input())
	s += temp
A = s.count('00') + s.count('11') + 1
print(A)


a = int(input())
d = ['xx']
for i in range(a):
	d.append(input())
count = 0
if len(d) == 1:
	print(1)
else:
	for i in range(0, a):
		if d[i] != d[i + 1]:
			count += 1
		else:
			pass
	print(count)


n = int(input())
e = 1
s = [input() for _ in range(n)]
for i in range(len(s) - 1):
	if s[i] != s[i + 1]:
		e += 1
print(e)


n = int(input())
s = input()
t1 = int(s[1])
n -= 1
k = 1
while n != 0:
	s1 = input()
	if int(s1[0]) == t1:
		k += 1
	t1 = int(s1[1])
	n -= 1
print(k)


n = int(input())
m = 0
l = []
for i in range(n):
	a = input()
	l.append(a)
for i in range(n - 1):
	if l[i][1] == l[i + 1][0]:
		m += 1
print(m + 1)


n = int(input())
l = []
for i in range(n):
	S = input()
	l.append(S)
k = 1
for i in range(n - 1):
	if l[i] != l[i + 1]:
		k = k + 1
print(k)


n = int(input())
m = []
p = k = 0
for i in range(n):
	m.append(input())
	if i == 0:
		continue
	elif m[i - 1] == m[i]:
		p += 1
	else:
		p = 0
		k += 1
print(k + 1)


n = eval(input())
magnets = []
group = 1
for i in range(n):
	magnets.append(int(input()))
for i in range(n - 1):
	if magnets[i] != magnets[i + 1]:
		group += 1
print(group)


no_of_magnets = int(input())
no_of_positions = 1
last_magnet = ''
for i in range(no_of_magnets):
	magnet_position = input()
	if i == 0:
		last_magnet = magnet_position
	elif last_magnet != magnet_position:
		no_of_positions += 1
		last_magnet = magnet_position
print(no_of_positions)


import sys, math
n = int(input())
count = 1
cur = input()
for i in range(n - 1):
	t = input()
	if cur != t:
		cur = t
		count += 1
print(count)


previous = '  '
group = 0
for _ in range(int(input())):
	magnet = str(input())
	if magnet[1] == previous[0]:
		group += 1
	previous = magnet
print(group + 1)


n = int(input())
line = [0] * n
for i in range(n):
	line[i] = list(input())
group = 1
for i in range(1, n):
	if line[i][0] == line[i - 1][1]:
		group += 1
print(group)


n = int(input())
no = '00'
ans = 0
for i in range(n):
	inp = input()
	if inp != no:
		ans += 1
		no = inp
print(ans)


a = [input() for _ in range(int(input()))]
print(1 + sum((1 for (x, y) in zip(a, a[1:]) if x != y)))


from sys import stdin
m = ''.join([x.rstrip() for x in stdin.readlines()][1:])
print(m.count('00') + m.count('11') + 1)


n = int(input())
count = 0
ls = [input() for x in range(n)]
for (i, j) in zip(ls, ls[1:]):
	if i != j:
		count += 1
print(count + 1)


n = int(input())
l = []
for i in range(n):
	l.append(input())
k = 1
for i in range(n - 1):
	if l[i][-1] != l[i + 1][0]:
		s = 1
	else:
		k += 1
print(k)


a = int(input())
count = 1
x = input()
for i in range(a - 1):
	y = input()
	if x != y:
		count += 1
		x = y
print(count)


import sys
n = int(input())
s = sys.stdin.readlines()
c = 0
for i in range(n - 1):
	if s[i] != s[i + 1]:
		c += 1
print(c + 1)


n = int(input())
out = 1
inp = input()
k = inp
for i in range(n - 1):
	inp = input()
	if inp != k:
		out += 1
	k = inp
print(out)


n = int(input())
last = input()
islands = 0
for i in range(n - 1):
	cur = input()
	if last[1] == '1' and cur[0] == '0' or (last[1] == '0' and cur[0] == '1'):
		last = cur
	else:
		last = cur
		islands += 1
print(islands + 1)


n = int(input())
m = []
for _ in range(n):
	m.append(input())
mm = ''.join(m)
x = mm.count('11')
y = mm.count('00')
print(x + y + 1)


last = ''
groups = 0
for _ in range(int(input())):
	s = input()
	if last != s:
		groups += 1
		last = s
print(groups)


t = int(input())
magnetOrientations = []
groups = 1
for i in range(t):
	mag = input()
	magnetOrientations.append(mag)
for i in range(1, len(magnetOrientations)):
	if magnetOrientations[i] != magnetOrientations[i - 1]:
		groups += 1
print(groups)


n = int(input())
g = 1
last = input()
for _ in range(n - 1):
	curr = input()
	if curr != last:
		g += 1
	last = curr
print(g)


cha = ''
slon = 0
n = int(input())
for i in range(n):
	t = input()
	if t[1] != cha:
		slon += 1
		cha = t[1]
print(slon)


def fun3():
	num = int(input())
	count = 1
	ls = []
	for i in range(num):
		x = int(input())
		ls.append(x)
	m = len(ls)
	for j in range(m - 1):
		if ls[j] != ls[j + 1]:
			count += 1
	print(count)
fun3()


i = input
s = l = 0
for x in [0] * int(i()):
	n = i()
	s += n != l
	l = n
print(s)


n = int(input())
g = 1
pre = input()
for i in range(n - 1):
	s = input()
	if pre[1] == s[0]:
		g += 1
	pre = s
print(g)


from sys import stdin, stdout
t = int(stdin.readline())
current = 0
groups = 0
for _ in range(t):
	next = int(stdin.readline())
	if next != current:
		groups += 1
	current = next
print(groups)


n = int(input())
list1 = []
count = 0
for i in range(n):
	s = input()
	list1.append(s)
for i in range(len(list1)):
	if i < len(list1) - 1:
		if list1[i] != list1[i + 1]:
			count += 1
	else:
		pass
print(count + 1)


n = int(input())
arr = []
count = 1
for _ in range(n):
	x = input()
	arr.append(x)
for i in range(n - 1):
	if arr[i] == '10' and arr[i + 1] == '01' or (arr[i] == '01' and arr[i + 1] == '10'):
		count += 1
print(count)


(y, c) = (0, 0)
for _ in range(int(input())):
	a = int(input())
	x = a
	if x != y:
		c += 1
		y = x
print(c)


import io
num_magnets = int(input())
magnets = []
answer = 0
last = ''
for i in range(0, num_magnets):
	a = input()
	magnets.append(a)
	if a != last:
		answer += 1
	last = a
print(answer)


n = int(input())
m = ''
g = 0
for i in range(n):
	a = input()
	if a != m:
		m = a
		g += 1
print(g)


mag = 1
n = int(input())
l = [input() for i in range(n)]
f = l[0]
for i in range(1, n):
	if l[i] != f:
		mag += 1
		f = l[i]
print(mag)


n = int(input())
out = 0
a1 = input()
for i in range(1, n):
	a2 = input()
	if a1 != a2:
		out += 1
	a1 = a2
print(out + 1)


x = input()
arr = []
s = set()
for i in range(int(x)):
	c = input()
	arr.append(c)
	s.add(c)
counter = 1
for i in range(len(arr) - 1):
	if arr[i] == arr[i + 1]:
		pass
	else:
		counter = counter + 1
print(counter)


n = int(input())
groups = 0
first = input()
for i in range(n - 1):
	inp = input()
	if first[0] != inp[0]:
		groups = groups + 1
		first = inp
print(groups + 1)


def magnet(n, ls):
	c = 1
	k = ls[0]
	for i in range(1, n):
		if k != ls[i]:
			c = c + 1
			k = ls[i]
	return c
n = int(input())
ls = [input() for i in range(n)]
print(magnet(n, ls))


n = int(input())
li = [input() for i in range(n)]
count = 1
for i in range(0, n - 1):
	if li[i] != li[i + 1]:
		count += 1
print(count)


n = int(input())
a = input()
g = 1
for x in range(1, n):
	next = input()
	if next == a:
		a = next
	else:
		a = next
		g = g + 1
print(g)


entr = int(input())
entrada = []
while entr:
	entrada.append(input())
	entr -= 1
ultimo = entrada[0]
cuantos = 1
for x in entrada[1:]:
	if x != ultimo:
		ultimo = x
		cuantos += 1
print(cuantos)


ans = 1
n = int(input())
list1 = []
for a in range(n):
	if a == n - 1:
		list1.append(str(input()))
		list1.append(list1[-1])
	else:
		list1.append(str(input()))
for i in range(n):
	if list1[i] != list1[i + 1]:
		ans += 1
print(ans)


a = int(input())
s = 1
d = input()
for i in range(a - 1):
	d1 = input()
	if d1 != d:
		s += 1
		d = d1
print(s)


n = int(input())
c = 1
v1 = int(input())
for i in range(n - 1):
	v2 = int(input())
	if v1 != v2:
		c += 1
		v1 = v2
print(c)


vals = int(input())
pos = []
for n in range(vals):
	oof = str(input())
	pos.append(oof)
n = 1
groups = 1
while n < vals:
	if str(pos[n]) != str(pos[n - 1]):
		groups += 1
	n += 1
print(groups)


n = int(input())
arr = []
c = 0
for i in range(n):
	nums = int(input())
	arr.append(nums)
for i in range(n - 1):
	if arr[i] == arr[i + 1]:
		c = c + 1
print(n - c)


n = int(input())
magnets = input()
groups_count = 1
for j in range(n - 1):
	i = input()
	if magnets[-1] != i[-1]:
		groups_count += 1
	magnets += i
print(groups_count)


n = int(input())
t = int(input()[0])
r = 1
for k in range(1, n):
	if int(input()[0]) != t:
		r += 1
		t = [1, 0][t]
print(r)


n = int(input())
arr = []
for i in range(n):
	x = input()
	arr.append(x)
count = 1
for i in range(1, n):
	if arr[i - 1] != arr[i]:
		count += 1
print(count)


size = int(input())
arr = []
for _ in range(size):
	arr.append(input())
ele = arr[0]
groups = 1
for i in range(1, size):
	if ele != arr[i]:
		ele = arr[i]
		groups += 1
print(groups)


from itertools import groupby
n = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
b = list([k for (k, g) in groupby(a)])
print(len(b))


def mod():
	n = int(input())
	k = []
	counter = 0
	for i in range(n):
		x = input().split()
		k.append(x)
	for j in range(len(k)):
		if j < n - 1:
			if k[j] != k[j + 1]:
				counter += 1
		else:
			print(counter + 1)
mod()


case = int(input())
magnet = []
for x in range(case):
	part = input()
	magnet.append(part)
count = 1
for x in range(case - 1):
	if magnet[x][1] == magnet[x + 1][0]:
		count += 1
print(count)


from sys import stdin, stdout
n = int(stdin.readline())
i = 0
a = int(stdin.readline())
c = 1
while i < n - 1:
	b = int(stdin.readline())
	if a != b:
		c += 1
	i += 1
	a = b
print(c)


n = int(input())
cnt = 0
prev = ''
for _ in range(n):
	i = input()
	if _ != 0:
		if i != prev:
			cnt += 1
	prev = i
print(cnt + 1)


n = int(input())
domino = []
count = 1
for i in range(n):
	mag = int(input())
	domino.append(mag)
	if domino[i] != domino[i - 1]:
		count += 1
print(count)


a = int(input())
k = 1
t = []
for i in range(a):
	a = int(input())
	t.append(a)
for i in range(len(t) - 1):
	if t[i] != t[i + 1]:
		k += 1
print(k)


a = int(input())
c = []
d = 1
for i in range(a):
	b = input()
	c.append(b)
for i in range(len(c) - 1):
	if c[i] == '10' and c[i + 1] == '01':
		d = d + 1
	elif c[i] == '01' and c[i + 1] == '10':
		d = d + 1
print(d)


n1 = input()
n = int(n1)
prev = ''
count = 0
for i in range(n):
	k = input()
	if k != prev:
		count += 1
		prev = k
print(count)


n = int(input())
k = 1
flag = input()
for i in range(n - 1):
	m = input()
	if m != flag:
		k += 1
		flag = m
print(k)


n = int(input())
t = ' '
c = 0
for i in ' ' * n:
	s = input()
	if s != t:
		c += 1
		t = s
print(c)


n = int(input())
o = 0
a = 0
b = 0
for i in range(n):
	s = input()
	if i % 2 != 0:
		a = s
	else:
		b = s
	if a == b:
		continue
	else:
		o += 1
print(o)


n = int(input())
p = 0
g = 0
for i in range(n):
	k = int(input())
	if p != k:
		g += 1
	p = k
print(g)


n = int(input())
c = 1
m = []
for i in range(n):
	m.append(input())
i = 0
while i != n - 1:
	if m[i] != m[i + 1]:
		c += 1
	i += 1
print(c)


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
m = 1
for i in range(n - 1):
	if arr[i] != arr[i + 1]:
		m = m + 1
print(m)


c = int(input())
res = oldI = 0
for i in range(c):
	newI = int(input())
	if newI != oldI:
		res += 1
	oldI = newI
print(res)


n = int(input())
t = []
c = 0
for i in range(n):
	t.append(input())
if n > 1:
	for i in range(1, n):
		if t[i - 1][1] == t[i][0]:
			c += 1
	print(c + 1)
else:
	print(1)


x = int(input())
a = input()
i = 1
k = 1
while i < x:
	t = input()
	if a != t:
		k += 1
	a = t
	i += 1
print(k)


a = []
q = int(input())
for i in range(q):
	a.append(str(input()))
y = 0
wy = 1
pom = 0
for i in range(len(a) - 1):
	if q == 1:
		break
	if a[pom] != a[pom + 1]:
		wy = wy + 1
	pom += 1
print(wy)


n = int(input())
j = int(input())
c = 1
for i in range(n - 1):
	k = int(input())
	if j != k:
		c += 1
		j = k
print(c)


(c, ans) = (0, 1)
for _ in range(int(input())):
	magnet = input()
	if c >= 1:
		if magnet[0] == f:
			ans += 1
	f = magnet[1]
	c += 1
print(ans)


N = int(input())
magnets = [int(input()) for x in range(N)]
count = 0
prev = 0
midx = 0
while midx < N:
	if magnets[midx] != prev:
		count += 1
	prev = magnets[midx]
	midx += 1
print(count)


n = input()
groups = 0
last = None
for i in range(int(n)):
	row = input()
	if last is None or last[-1] == row[0]:
		groups += 1
	last = row
print(groups)


number_of_magnets = int(input())
list_number = []
count = 0
for i in range(0, number_of_magnets):
	list_number.append(input())
len_list_number = len(list_number)
for j in range(0, len_list_number - 1):
	if list_number[j] == '10' and list_number[j + 1] == '01':
		count += 1
	if list_number[j] == '01' and list_number[j + 1] == '10':
		count += 1
print(count + 1)


n = int(input())
cnt = 0
prev = ''
for _ in range(n):
	x = input()
	cnt += x != prev
	prev = x
print(cnt)


(count, list1) = (0, [])
for i in range(int(input())):
	list1.append(int(input()))
for j in range(1, len(list1)):
	if list1[j] != list1[j - 1]:
		count += 1
print(count + 1)


n = int(input())
a = []
count = 1
for i in range(n):
	temp = int(input())
	a.append(temp)
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		pass
	elif a[i] != a[i + 1]:
		count = count + 1
print(count)


n = int(input())
last = int(input())
islands = 1
for i in range(n - 1):
	current = int(input())
	if current != last:
		islands += 1
		last = current
print(islands)


ans = 1
x = int(input())
s = input()
for i in range(1, x):
	s2 = input()
	if s2[0] == s[1]:
		ans += 1
	s = s2
print(ans)


n = int(input())
a = []
for _ in range(n):
	a.append(input())
b = ''.join(a)
count = 1
for i in range(len(b) - 1):
	if b[i] == '1' and b[i + 1] == '1':
		count += 1
	if b[i] == '0' and b[i + 1] == '0':
		count += 1
print(count)


n = int(input())
a = []
start = input()
num = 1
temp = start
for i in range(n - 1):
	b = input()
	if b != temp:
		num += 1
	temp = b
print(num)


n = int(input())
k = []
count = 1
for x in range(n):
	k.append(input()[:2])
for x in range(len(k)):
	try:
		if k[x] != k[x + 1]:
			count += 1
	except:
		continue
print(count)


x = 0
p = ''
for i in range(int(input())):
	s = input()
	if s == p:
		continue
	else:
		x += 1
		p = s
print(x)


inp = int(input())
lst = []
for i in range(0, inp):
	ele = int(input())
	lst.append(ele)
count = 0
for i in range(0, inp - 1):
	if lst[i] != lst[i + 1]:
		count = count + 1
print(count + 1)


a = int(input())
m1 = 0
m2 = 0
c = 1
m1 = input()
for i in range(a - 1):
	m2 = input()
	if m1 != m2:
		c = c + 1
	m1 = m2
print(c)


n = int(input())
l = []
for i in range(n):
	u = input()
	l += [u]
c = 1
for i in range(n - 1):
	if l[i][-1] == l[i + 1][0]:
		c += 1
print(c)


n = int(input())
c = 1
lst = []
for i in range(n):
	s1 = input()
	s = s1.split()
	lst.append(s)
for i in range(n - 1):
	if lst[i] == lst[i + 1]:
		continue
	else:
		c += 1
print(c)


n = int(input())
v = 0
c = '0'
l = []
for i in range(0, n):
	l.append(input())
	if i == 0:
		c = l[0][-1]
	elif l[i][0] != c:
		c = l[i][-1]
		continue
	else:
		v += 1
		c = l[i][-1]
print(v + 1)


n = int(input())
count = old = 0
for i in range(n):
	new = input()
	count += new != old
	old = new
print(count)


n = int(input(''))
domino = int(input(''))
count = 1
for i in range(0, n - 1):
	num = int(input(''))
	if num != domino:
		count += 1
		domino = num
print(count)


x = int(input())
y = []
for i in range(0, x):
	y.append(input())
z = ''.join(y)
a = z.split('00')
b = 0
for j in a:
	b += len(j.split('11')) - 1
print(len(a) + b)


def magnets(arr):
	stack = [arr[0]]
	for i in range(1, len(arr)):
		if arr[i] != stack[-1]:
			stack.append(arr[i])
	return len(stack)
n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().rstrip().split())))
print(magnets(arr))


n = int(input())
m = []
for _ in range(n):
	x = input()
	m.append(x)
x = 1
for i in range(1, n):
	if m[i] == '10' and m[i - 1] == '10':
		pass
	elif m[i] == '01' and m[i - 1] == '01':
		pass
	elif m[i] == '10' and m[i - 1] == '01':
		x += 1
	else:
		x += 1
print(x)


x = int(input())
l = []
for c in range(x):
	l.append(int(input()))
pairs = 1
for c in range(1, x):
	if l[c] != l[c - 1]:
		pairs = pairs + 1
print(pairs)


n = int(input())
a = []
for i in range(n):
	a.append(input())
s = ''.join(a)
m = s[0]
count = 0
for char in s:
	if char == m:
		count = count + 1
	m = char
print(count)


n = int(input())
x = input()
c = 0
for i in range(1, n):
	y = input()
	if x == y:
		pass
	else:
		c += 1
		x = y
print(c + 1)


n = int(input())
li = []
for _ in range(n):
	ins = int(input())
	li.append(ins)
c = 1
for i in range(len(li) - 1):
	if li[i] != li[i + 1]:
		c += 1
print(c)


n = int(input())
l = []
for i in range(n):
	ai = int(input())
	l.append(ai)
count = 0
for i in range(len(l) - 1):
	if l[i] == l[i + 1]:
		continue
	else:
		count += 1
print(count + 1)


n = int(input())
count = 1
for i in range(n):
	x = int(input())
	if i == 0:
		y = x
	elif y == x:
		continue
	else:
		count += 1
		y = x
print(count)


a = input()
a = int(a)
b = input()
b = str(b)
i = 2
x = 0
while i <= a:
	c = input()
	c = str(c)
	i = i + 1
	if b != c:
		x = x + 1
		b = c
print(x + 1)


n = int(input())
magnets = []
for _ in range(n):
	magnets.append(input())
lastsign = ''
islands = 0
for i in range(n):
	if magnets[i][0] == lastsign:
		islands = islands + 1
	lastsign = magnets[i][1]
print(islands + 1)


number_of_magnet = int(input())
list_of_magnet = []
for i in range(number_of_magnet):
	magnet = input()
	list_of_magnet.append(magnet)
gp = 1
for i in range(len(list_of_magnet) - 1):
	if not list_of_magnet[i + 1] == list_of_magnet[i]:
		gp += 1
print(gp)


x = int(input())
y = 1
a = input()
for i in range(x - 1):
	z = input()
	if a[-1] == z[0]:
		y += 1
	a = z
print(y)


n = int(input())
num = 1
i = 0
old = input()
while i < n - 1:
	new = input()
	if new != old:
		num += 1
	old = new
	i += 1
print(num)


n = int(input())
cnt = 0
i = 0
b = 0
while n > 0:
	s = input()
	b = 0
	if i != 0:
		if p != s:
			cnt = cnt + 1
			b = 1
	p = s
	i = i + 1
	n = n - 1
print(cnt + 1)


n = int(input())
s = ''
for i in range(n):
	s = s + input()
c = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		c = c + 1
print(c + 1)


x = int(input())
inp = []
ans = 0
for i in range(x):
	cv = input()
	inp.append(cv)
for i in range(x - 1):
	if inp[i] != inp[i + 1]:
		ans += 1
	else:
		pass
print(ans + 1)


t = int(input())
str1 = 'xy'
cn = 0
for i in range(t):
	s1 = input()
	if s1[0] == str1[1]:
		cn += 1
	str1 = s1
print(cn + 1)


n = int(input())
s = ''
while n > 0:
	s += input()
	n -= 1
print(s.count('00') + s.count('11') + 1)


n = int(input())
mag_list = []
for magnet in range(n):
	mag_list.append(input())
joined = ''.join(mag_list)
print(joined.count('00') + joined.count('11') + 1)


n = int(input())
x = [0] * n
c = 0
t = 0
j = 0
for i in range(n):
	x[i] = input()
j = x[0][0]
c += 1
for i in range(len(x)):
	if x[i][0] != j:
		j = x[i][0]
		c += 1
print(c)


a = int(input())
li = []
k = 1
for i in range(a):
	b = int(input())
	li.append(b)
for i in range(a - 1):
	if not li[i] == li[i + 1]:
		k += 1
print(k)


n = int(input())
count = 1
start = input()
while n - 1:
	temp1 = input()
	if temp1 != start:
		start = temp1
		count += 1
	n -= 1
print(count)


n = int(input())
last = -1
ans = 0
for i in range(n):
	a = input()
	if last == -1 or last == a[0]:
		ans += 1
	last = a[1]
print(ans)


t = int(input())
st1 = input()
t = t - 1
count = 1
while t != 0:
	n = input()
	if st1 != n:
		count = count + 1
	st1 = n
	t = t - 1
print(count)


count = 1
previous = None
for _ in range(int(input())):
	magnet = input()
	if previous == magnet[0]:
		count += 1
		previous = magnet[-1]
	if previous is None:
		previous = magnet[-1]
print(count)


liczbaMagnesow = int(input())
suma = 1
napis = ''
znak = 0
for x in range(liczbaMagnesow):
	magnes = input()
	if x > 0:
		if int(magnes[0]) == znak:
			suma += 1
	znak = int(magnes[1])
print(suma)


n = int(input())
(arr, res) = ([], 1)
for i in range(n):
	s = str(input())
	arr.append(s)
for i in range(n):
	if i > 0 and arr[i] != arr[i - 1]:
		res += 1
print(res)


n = int(input())
c = 1
sm = []
for i in range(n):
	sm.append(input())
sm = ''.join(sm)
c += sm.count('11') + sm.count('00')
print(c)


inp = []
for i in range(int(input())):
	inp.append(input())
c = 1
ans = []
for i in range(len(inp) - 1):
	if inp[i] == inp[i + 1]:
		c += 1
	else:
		ans.append(c)
		c = 1
print(len(ans) + 1)


t = int(input())
prev_magnet = ''
groups = 1
for i in range(t):
	mag = input()
	if i != 0:
		if mag[0] == prev_magnet[1]:
			groups += 1
	prev_magnet = mag
print(groups)


a = int(input())
i = int(0)
b = input()
k = int(1)
while i < a - 1:
	c = input()
	if b != c:
		k = k + 1
	b = c
	i = i + 1
print(k)


import sys
input = sys.stdin.readline
n = int(input())
magnets = [input().strip() for _ in range(n)]
cnt = 1
prev = magnets[0]
for m in magnets[1:]:
	if m != prev:
		prev = m
		cnt += 1
print(cnt)


n = int(input())
seq = []
res = 1
for i in range(0, n):
	seq.append(input())
for i in range(1, n):
	if seq[i] != seq[i - 1]:
		res += 1
print(res)


n = int(input())
temp = input()
count = 1
for i in range(n - 1):
	temp2 = input()
	if temp2 == temp:
		continue
	else:
		temp = temp2
		count += 1
print(count)


n = int(input())
l = []
while n:
	l.append(int(input()))
	n -= 1
count = 1
for i in range(0, len(l) - 1):
	if l[i] != l[i + 1]:
		count += 1
print(count)


n = int(input())
m = ''
for _ in range(n):
	m += input()
m = m.replace('00', '.')
m = m.replace('11', '.')
print(len(m.split('.')))


n = int(input())
g = 0
z = 0
for i in range(n):
	c = z
	q = int(input())
	z = q
	if i > 0:
		if q - c == 0:
			g += 0
		elif q - c != 0:
			g += 1
	elif i == 0:
		g += 1
		continue
print(g)


from sys import stdin
N = int(stdin.readline())
divide = 0
cur = stdin.readline()
for magnet in range(N - 1):
	mag = stdin.readline()
	if cur != mag:
		divide += 1
	cur = mag
print(divide + 1)


n = int(input())
s = []
c = 1
for i in range(n):
	row = input()
	s.append(row)
for i in range(n - 1):
	if s[i][-1] == s[i + 1][0]:
		c += 1
print(c)


n = int(input())
a = []
for i in range(0, n, 1):
	no = int(input())
	a.append(no)
g = 1
for i in range(1, n, 1):
	if a[i - 1] != a[i]:
		g += 1
print(g)


g = 0
c = 0
for t in range(int(input())):
	n = int(input())
	if n == c:
		c = n
	else:
		g += 1
		c = n
print(g)


y = []
count = 1
x = int(input())
for i in range(x):
	z = int(input())
	y.append(z)
for j in range(len(y) - 1):
	if y[j] != y[j + 1]:
		count += 1
print(count)


import sys
n = int(sys.stdin.readline())
magnet_list = [''] * n
(magnet_list[0], group) = (input(), 1)
for i in range(1, n):
	magnet_list[i] = input()
	if not magnet_list[i] == magnet_list[i - 1]:
		group += 1
print(group)


L = []
k = 1
n = int(input())
for i in range(n):
	a = input()
	L.append(a)
for i in range(1, len(L)):
	if L[i] != L[i - 1]:
		k += 1
print(k)


def solve():
	n = int(input())
	magnets = []
	for i in range(n):
		magnets.append(input())
	ans = 1
	for i in range(1, len(magnets)):
		if magnets[i] == magnets[i - 1]:
			continue
		else:
			ans += 1
	return ans

def main():
	print(solve())
main()


n = int(input()) - 1
s = input()
k = 1
while n != 0:
	n -= 1
	if input() != s:
		k += 1
		s = s[::-1]
print(k)


n = int(input())
lista = list()
for i in range(n):
	m = str(input())
	lista.append(m)
j = 0
contador = 0
while True:
	if j == n - 1:
		break
	if lista[j] == lista[j + 1]:
		j += 1
		continue
	else:
		contador += 1
		j += 1
print(contador + 1)


n = int(input())
l = []
c = 1
for i in range(n):
	s = input()
	l.append(s)
t = len(l)
for i in range(0, t - 1):
	j = i + 1
	if l[i] == l[j]:
		pass
	else:
		c = c + 1
print(c)


n = int(input())
c = 0
x = ''
for _ in range(n):
	g = input()
	if g != x:
		c += 1
		x = g
print(c)


n = int(input())
l = ''
for i in range(n):
	l += input()
print(l.count('00') + l.count('11') + 1)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
temp = l[0]
g = 1
for i in range(1, n):
	if l[i] != temp:
		g += 1
		temp = l[i]
print(g)


N = int(input())
lista = []
for i in range(N):
	num = input()
	lista += [num]
cont = 1
for i in range(1, len(lista)):
	if lista[i][0] == lista[i - 1][-1]:
		cont += 1
print(cont)


n = int(input())
magnets = ''
for x in range(n):
	magnets += input()
magnets = magnets.replace('00', 'x')
magnets = magnets.replace('11', 'x')
magnets = magnets.split('x')
print(len(magnets))


n = int(input())
t = 1
l = []
for i in range(n):
	x = int(input())
	l.append(x)
for i in range(n - 1):
	if l[i] == l[i + 1]:
		continue
	else:
		t += 1
print(t)


x = int(input(''))
list = []
m = 1
for c in range(x):
	y = input('')
	list.append(y)
for c in range(x):
	if c == x - 1:
		print(m)
		exit()
	if list[c] != list[c + 1]:
		m += 1


n = int(input())
d = 1
y = []
for i in range(n):
	x = str(input())
	y.append(x)
for i in range(len(y)):
	y[i] = int(y[i])
for i in range(len(y) - 1, 0, -1):
	if y[i] != y[i - 1]:
		d = d + 1
print(d)


def shiftsInNums(n, arr):
	count = 1
	for i in range(1, n):
		if arr[i - 1] != arr[i]:
			count += 1
	return count
n = int(input())
arr = []
for i in range(n):
	temp = input()
	arr.append(temp)
print(shiftsInNums(n, arr))


n = int(input())
m = [input() for _ in range(n)]
print(1 if len(m) == 1 else sum((0 if m[i] == m[i + 1] else 1 for i in range(len(m) - 1))) + 1)


(a, p) = (0, 0)
for _ in '.' * int(input()):
	s = input()
	a += s != p
	p = s
print(a)


T = int(input())
K = 1
R = int(input())
for I in range(T - 1):
	S = int(input())
	if S != R:
		R = S
		K += 1
print(K)


n = int(input())
line = ''
for i in range(n):
	new = str(input())
	line = line + new
count = 1
for i in range(len(line) - 1):
	if line[i] == line[i + 1]:
		count += 1
print(count)


n = int(input())
groups = 0
prev = ''
for _ in range(n):
	c = input()
	if c != prev:
		groups += 1
		prev = c
print(groups)


n = int(input())
islands = 0
sP = ''
for i in range(n):
	s = input()
	if sP != s:
		islands += 1
		sP = s
print(islands)


def read_input():
	number_magnets_input = int(input())
	list_input = []
	counter = 0
	while number_magnets_input > 0:
		value = 1 if input() == '10' else 0
		if len(list_input) == 0:
			list_input.append(value)
		if value != list_input[len(list_input) - 1]:
			counter += 1
			list_input.append(value)
		number_magnets_input -= 1
	return counter + 1
print(read_input())


a = int(input())
s = 0
j = 0
for i in range(0, a):
	b = int(input())
	if j != b:
		s = s + 1
		j = b
	else:
		j = b
print(s)


repetition = int(input())
groups = 1
str_magnets = []
for times in range(repetition):
	pair = input()
	for num in pair:
		str_magnets.append(num)
list_magnets = list(map(int, str_magnets))
for poles in range(len(list_magnets)):
	if poles == repetition * 2 - 1:
		break
	elif list_magnets[poles] == list_magnets[poles + 1]:
		groups += 1
print(groups)


try:
	n = int(input())
	ans = 9
	p = 0
	for i in range(n):
		a = input()
		if ans != a:
			ans = a
			p += 1
	print(p)
except:
	pass


n = int(input())
s = 'aa'
c = 1
for k in range(n):
	a = input()
	if a[0] == s[1]:
		c = c + 1
	s = a
print(c)


n = int(input())
a = []
for _ in range(0, n):
	s = input()
	a.append(s)
c = 0
if len(a) == 1:
	print(1)
else:
	for i in range(0, len(a) - 1):
		if a[i] == '01' and a[i + 1] == '01' or (a[i] == '10' and a[i + 1] == '10'):
			c = c + 1
	if c == 0:
		print(len(a))
	else:
		print(len(a) - c)


n = int(input())
l = []
for i in range(n):
	digit = list(input())
	l.append(digit[0])
	l.append(digit[1])
num = [1]
for i in range(2, len(l), 2):
	e = 1
	if l[i] != l[i - 1]:
		e += 1
	if l[i] == l[i - 1]:
		num.append(e)
print(len(num))


a = int(input())
b = [None] * a
ans = 0
for i in range(0, a):
	b[i] = input()
for i in range(1, a):
	if b[i] != b[i - 1]:
		ans += 1
print(ans + 1)


gr = 0
l = []
for i in range(int(input())):
	i = int(input())
	l.append(i)
for x in range(len(l) - 1):
	if l[x] != l[x + 1]:
		gr += 1
print(gr + 1)


n_l = [input() for i in range(int(input()))]
print(1 + sum((x != y for (x, y) in zip(n_l, n_l[1:]))))


n = int(input())
count = 1
last = int(input()[1])
for i in range(n - 1):
	temp = input()
	if last == int(temp[0]):
		count += 1
	last = int(temp[1])
print(count)


arr = []
count = 0
for _ in range(int(input())):
	mag = input()
	arr.append(mag)
first = arr[0]
for i in range(1, len(arr)):
	if arr[i - 1] == arr[i]:
		continue
	else:
		count += 1
		first = arr[i]
print(count + 1)


x = int(input())
l = []
m = []
for i in range(0, x):
	n = int(input())
	m.append(n)
for j in range(len(m) - 1):
	if m[j] == m[j + 1]:
		count = 0
		l.append(count)
	else:
		count = 1
		l.append(count)
print(sum(l) + 1)


n = int(input())
cnt = 1
s = input()
for i in range(n - 1):
	x = input()
	if x != s:
		cnt += 1
		s = x
print(cnt)


p = f = 0
for s in [*open(0)][1:]:
	f += p != s
	p = s
print(f)


(inp, result) = ([], 1)
for i in range(int(input())):
	inp.append(input())
	if i >= 1:
		if inp[i - 1][1] == inp[i][0]:
			result += 1
print(result)


n = int(input())
count = 1
p = int(input())
for i in range(n - 1):
	c = int(input())
	if p != c:
		count += 1
	p = c
print(count)


n = int(input())
k = ''
for i in range(n):
	k += input()
a = ['11', '00']
print(k.count(a[0]) + k.count(a[1]) + 1)


n = int(input())
previous_d = '00'
counter = int()
for i in range(n):
	d = input()
	if d != previous_d:
		counter += 1
	previous_d = d
print(counter)


n = int(input())
i = 1
count = 1
a = input()
while i < n:
	i = i + 1
	x = input()
	if x != a:
		count = count + 1
		a = x
print(count)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
m = 0
for s in range(0, n - 1):
	if l[s] != l[s + 1]:
		m += 1
print(m + 1)


n = int(input())
first = True
tmp = 0
ncount = 1
for i in range(n):
	l = int(input())
	if first:
		first = False
		tmp = l
		continue
	if l != tmp:
		ncount += 1
		tmp = l
print(ncount)


result_list = []
n = int(input())
string = '22'
for i in range(n):
	i = input()
	if i[0] != string[-1]:
		string += i
	else:
		result_list.append(string)
		string = '22' + i
result_list.append(string)
print(len(result_list))


n = int(input())
count = 0
currentGroupState = ''
while n:
	n -= 1
	m = input()
	if not m == currentGroupState:
		count += 1
		currentGroupState = m
print(count)


n = int(input())
i = 0
m = 1
s = 1
a = 0
b = list()
while i in range(n):
	a = input()
	b.append(a)
	i += 1
while m in range(len(b)):
	if b[m - 1] == b[m]:
		s = s
	else:
		s = s + 1
	m += 1
print(s)


class Magnets:
	n = 0
	magnets = list()

	def solve(self):
		if len(self.magnets) == 0:
			return 0
		count = 1
		lastPole = self.magnets[0][1]
		for i in range(1, self.n):
			if self.magnets[i][0] == lastPole:
				count += 1
			lastPole = self.magnets[i][1]
		return count
m = Magnets()
m.n = int(input())
_n = 0
while _n < m.n:
	m.magnets.append(input())
	_n += 1
print(m.solve())


s = []
n = int(input())
for i in range(n):
	s.append(input())
result = []
x = [s[0]]
for i in range(1, len(s)):
	if s[i - 1][1] == s[i][0]:
		result.append(x)
		x = []
		x.append(s[i])
	else:
		x.append(s[i])
if x:
	result.append(x)
print(len(result))


num = int(input())
poles = []
group = 0
for i in range(num):
	poles.append(input())
for i in range(num - 1):
	if int(poles[i]) != int(poles[i + 1]):
		group += 1
print(group + 1)


n = int(input())
l = []
c = 1
for i in range(n):
	x = int(input())
	l.append(x)
for i in range(n - 1):
	if l[i] != l[i + 1]:
		c += 1
print(c)


n = int(input())
a = []
k = 0
for i in range(n):
	b = list(input())
	c = b[0]
	d = b[1]
	a.append(c)
	a.append(d)
for i in range(1, len(a) - 1, 2):
	if a[i] == a[i + 1]:
		k += 1
print(k + 1)


end = ''
numOfRows = 0
for i in range(int(input())):
	cwr = input()
	if cwr[1] != end:
		numOfRows += 1
	end = cwr[1]
print(numOfRows)


from sys import stdin
from sys import stdout

def readdata():
	global n, a
	n = int(stdin.readline())
	a = []
	for i in range(n):
		a.append(int(stdin.readline()))

def solve():
	kol = 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			kol += 1
	print(kol)
readdata()
solve()


def magnets(n):
	count = 0
	temp = ''
	while n > 0:
		new = input()
		if temp != new:
			count += 1
		temp = new
		n -= 1
	return count
n = int(input())
print(magnets(n))


n = int(input())
w = 0
r = 0
for i in range(n):
	a = int(input())
	if a != r:
		w = w + 1
	r = a
print(w)


last = '99'
ans = 0
for _ in range(int(input())):
	mag = input()
	if last != mag:
		ans += 1
	last = mag
print(ans)


def get_groups():
	count = 1
	prev = magnets[0]
	for mag in magnets[1:]:
		if mag == prev:
			continue
		count += 1
		prev = mag
	return count
n = int(input())
magnets = []
for i in range(n):
	magnets.append(input())
print(get_groups())


n = int(input())
arr = []
arr.append(int(input()))
cnt = 0
for i in range(1, n):
	arr.append(int(input()))
	if arr[i] == arr[i - 1]:
		pass
	else:
		cnt = cnt + 1
print(cnt + 1)


n = int(input())
ans = 0
prev = '00'
for _ in range(n):
	s = input()
	if s != prev:
		ans += 1
		prev = s
print(ans)


import sys
ms = sys.stdin.readlines()[1:]
print(sum([1 for (a, b) in zip(ms, ms[1:]) if a != b]) + 1)


n = int(input())
magnets = []
for i in range(n):
	magnets.append(input())
c = 1
for i in range(n - 1):
	if magnets[i][1] == magnets[i + 1][0]:
		c += 1
print(c)


a = []
for _ in range(int(input())):
	p = input()
	a.append(p)
c = 0
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		c += 1
print(c + 1)


n = int(input())
tmp = input()
cnt = 1
for i in range(n - 1):
	t = input()
	if tmp != t:
		cnt += 1
	tmp = t
print(cnt)


t = 1
s = ''
for i in range(int(input())):
	a = input()
	if a[0] == s:
		t += 1
		s = a[-1]
	else:
		s = a[-1]
print(t)


n = int(input())
pre = '--'
group = 0
for i in range(n):
	s = input()
	if s != pre:
		group += 1
	pre = s
print(str(group))


n = int(input())
k = 1
x = input()
for i in range(n - 1):
	y = input()
	if y != x:
		k += 1
		x = y
print(k)


n = int(input())
g = 0
pstate = 2
for i in range(0, n):
	m = list(input())
	if pstate == 2:
		g += 1
		pstate = m[1]
		continue
	if m[1] == pstate:
		pstate = m[1]
	else:
		g += 1
		pstate = m[1]
print(g)


c = 1
n = int(input())
lst = []
for i in range(n):
	lst.append(input())
for i in range(n - 1):
	if lst[i] == lst[i + 1]:
		continue
	else:
		c += 1
print(c)


n = int(input())
l = n * ['']
for i in range(n):
	l[i] = input()
t = 1
s = l[0]
for i in range(1, n):
	if l[i] != s:
		t = t + 1
		s = l[i]
print(t)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
t = int(input())
prev = input()
ans = 1
for _ in range(t - 1):
	s = input()
	if s != prev:
		prev = s
		ans += 1
print(ans)


import sys
n = int(sys.stdin.readline()[:-1])
magnet = sys.stdin.readline()[:-1]
last = magnet[-1]
output = 1
for i in range(n - 1):
	magnet = sys.stdin.readline()[:-1]
	if magnet[0] == last:
		output += 1
		last = magnet[-1]
print(output)


n = int(input())
count = 0
island = 0
for i in range(n):
	a = int(input())
	if island != a:
		count += 1
		island = a
	else:
		continue
print(count)


n = int(input())
liste = []
x = 0
while x < n:
	ekleme = int(input())
	liste.append(ekleme)
	x += 1
grupsayisi = 1
for i in range(n):
	if i == 0:
		continue
	elif liste[i] != liste[i - 1]:
		grupsayisi += 1
	else:
		continue
print(grupsayisi)


num = int(input())
i = 0
mag_list = []
while i < num:
	mag_list.append(input())
	i += 1
mag_list.append(' ')
i = 0
counter = 0
for element in mag_list:
	if i == num:
		break
	if mag_list[i] == mag_list[i + 1]:
		i += 1
	else:
		i += 1
		counter += 1
print(counter)


n = int(input())
(groups, i, current_m) = (0, 0, '')
while i < n:
	magnet = input()
	if magnet != current_m:
		groups += 1
	current_m = magnet
	i += 1
print(groups)


n = int(input())
arr = [int(input()) for i in range(n)]
arr = [arr[i] for i in range(1, len(arr)) if arr[i] != arr[i - 1]]
print(len(arr) + 1)


n = int(input())
count = 1
s1 = input()
for i in range(n - 1):
	s = input()
	if s != s1:
		count += 1
		s1 = s
print(count)


n = int(input())
c = 1
s = input()
while n - 1:
	t = input()
	if s == t:
		pass
	else:
		s = t
		c += 1
	n -= 1
print(c)


def number():
	n = int(input())
	if n == 1:
		return 1
	(prev, curr, counter) = (input(), input(), 0)
	if curr != prev:
		counter += 1
	for i in range(n - 2):
		(prev, curr) = (curr, input())
		if curr != prev:
			counter += 1
	return counter + 1
print(number())


n = int(input())
a = []
for i in range(n):
	a.append(input())
k = 0
for i in range(1, n):
	if int(a[i - 1]) != int(a[i]):
		k += 1
print(k + 1)


n = int(input())
g = 1
for i in range(n):
	if i == 0:
		lst = input()
	else:
		temp = input()
		if lst[1] == temp[0]:
			g += 1
		lst = temp
print(g)


a = int(input())
buffer = ''
check = 0
count = 0
while a != 0:
	t = input()
	if check == 0:
		check = 1
		buffer = t
		count += 1
	elif buffer != t:
		count += 1
		buffer = t
	a -= 1
print(count)


n = int(input())
sum = 1
for i in range(0, n):
	s = input()
	if i != 0:
		if s != last:
			sum += 1
	last = s
print(sum)


test_cases = int(input())
pair = 0
latest = '00'
magnet_pair = []
for i in range(test_cases):
	magnet_pair.append(input())
	if latest != magnet_pair[i]:
		pair += 1
	latest = magnet_pair[i]
print(pair)


n = int(input())
c = 0
b = 0
while n != 0:
	a = input()
	if a != b:
		c = c + 1
		b = a
	n = n - 1
print(c)


t = int(input())
a = []
for i in range(t):
	a.append(int(input()))
c = 1
for i in range(t - 1):
	if a[i] != a[i + 1]:
		c += 1
print(c)


srit = ''
for i in range(int(input())):
	ina = input()
	srit += ina
dreit = srit.replace('00', '0 0')
cret = dreit.replace('11', '1 1')
print(cret.count(' ') + 1)


n = int(input())
prev = int(input())
count = 1
for i in range(n - 1):
	m = int(input())
	if m != prev:
		count += 1
		prev = m
print(count)


n = int(input())
magnets = [['', ''] for i in range(n)]
num = 1
for i in range(n):
	l = list(input())
	magnets[i][0] = l[0]
	magnets[i][1] = l[1]
	if i > 0:
		if magnets[i - 1][1] == magnets[i][0]:
			num += 1
print(num)


x = int(input())
array = []
for i in range(x):
	y = input()
	array.append(y)
lastone = ''
total = 0
for i in range(x):
	if array[i] != lastone:
		total += 1
		lastone = array[i]
	else:
		lastone = array[i]
print(total)


n = int(input())
a = []
b = 1
for i in range(n):
	m = input()
	a += [m]
for i in range(len(a)):
	if i == len(a) - 1:
		break
	elif a[i] != a[i + 1]:
		b += 1
print(b)


n = int(input())
magnet_l = []
group = 1
for i in range(n):
	position = input()
	magnet_l.append(position)
for x in range(n - 1):
	if magnet_l[x] != magnet_l[x + 1]:
		group += 1
print(group)


def isAttracted(a, b):
	if a[1] == b[0]:
		return False
	else:
		return True

def main():
	c = 1
	n = int(input())
	m1 = ''
	m2 = input()
	for i in range(1, n):
		(m1, m2) = (m2, input())
		if not isAttracted(m1, m2):
			c += 1
	print(c)
main()


n = int(input())
l = []
count = 0
for i in range(n):
	k = int(input())
	l.append(k)
	if i > 0 and k != l[i - 1]:
		count += 1
print(count + 1)


n = int(input())
ch = input()
j = 0
for i in range(n - 1):
	ch1 = input()
	if ch != ch1:
		j += 1
	ch = ch1
print(j + 1)


n = int(input())
ip = []
for i in range(n):
	ip.append(input().strip())
c = ip[0]
numgps = 1
for m in ip[1:]:
	if m != c:
		c = m
		numgps += 1
print(numgps)


n = int(input())
b = []
for j in range(n):
	b.append(input())
c1 = 1
for i in range(1, n):
	if b[i - 1][1] == b[i][0]:
		c1 += 1
print(c1)


from sys import *
c = 0
n = int(stdin.readline())
s = '11'
for u in range(n):
	q = stdin.readline()
	if q != s:
		c = c + 1
		s = q
print(c)


n = int(input())
prev = input()
cnt = 1
for i in range(n - 1):
	curr = input()
	if prev == curr:
		continue
	cnt += 1
	prev = curr
print(cnt)


n = int(input())
n1 = []
for i in range(n):
	l = input()
	n1.append(l)
k = 1
for i in range(len(n1) - 1):
	if n1[i] != n1[i + 1]:
		k = k + 1
print(k)


in1 = int(input())
ans = 1
in2 = input()
for _ in range(in1 - 1):
	in3 = input()
	if in2 != in3:
		ans += 1
		in2 = in3
print(ans)


n = int(input())
gr = 1
lst = []
for i in range(n):
	s = input()
	lst.append(s)
ln = len(lst)
for j in range(ln - 1):
	cur = lst[j]
	nxt = lst[j + 1]
	if cur != nxt:
		gr += 1
print(gr)


group = 1
n = int(input())
m = input()
for i in range(1, n):
	n = input()
	if m != n:
		group += 1
	m = n
print(group)


n = int(input())
magnets = []
for i in range(n):
	temp = input()
	magnets.append(temp)
count = 0
for i in range(n - 1):
	if magnets[i] != magnets[i + 1]:
		count = count + 1
count = count + 1
print(count)


n = int(input())
l = [input() for x in range(n)]
i = 1
count = 1
while i < n:
	if l[i][0] != l[i - 1][0]:
		count += 1
	i += 1
print(count)


from sys import stdin, stdout
group = 1
magnets = int(stdin.readline())
last_chr = stdin.readline()[-2]
i = 1
while i < magnets:
	i += 1
	domino = stdin.readline()
	first_chr = domino[0]
	if last_chr == first_chr:
		group += 1
	last_chr = domino[-2]
stdout.write(str(group) + '\n')


n = int(input())
t = input()
c = 0
for i in range(n - 1):
	temp = input()
	if t != temp:
		c += 1
	t = temp
print(c + 1)


import sys
x = []
for line in sys.stdin:
	x.append(line.strip().split())
blocks = 1
for i in range(1, len(x) - 1):
	if x[i] != x[i + 1]:
		blocks += 1
print(blocks)


k = int(input())
A = []
s = 1
for i in range(k):
	A.append(int(input()))
for i in range(len(A) - 1):
	if A[i] != A[i + 1]:
		s = s + 1
print(s)


num = int(input())
mags = [None] * num
for i in range(num):
	mags[i] = str(input())
check = mags[0]
count = 0
for j in range(len(mags)):
	if check != mags[j]:
		check = mags[j]
		count = count + 1
	else:
		continue
print(count + 1)


n = int(input())
count = 0
now = ''
for i in range(n):
	magnet = str(input())
	if magnet != now:
		count += 1
		now = magnet
print(count)


n = int(input())
g = input()
l = 1
for i in range(n - 1):
	s = input()
	if g != s:
		l += 1
	g = s
print(l)


n = int(input())
arr = []
for i in range(n):
	m = input()
	arr.append(m)
groups = 1
for i in range(1, len(arr)):
	if arr[i - 1][1] == arr[i][0]:
		groups += 1
print(groups)


n = int(input())
l = []
count = 0
first_time = True
for i in range(n):
	l.append(input())
	if first_time:
		first_time = False
	elif l[i - 1] != l[i]:
		count += 1
	if i == n - 1:
		count += 1
print(count)


t = int(input())
n = []
for i in range(t):
	p = int(input())
	n.append(p)
count = 0
for i in range(t - 1):
	if n[i] != n[i + 1]:
		count += 1
print(count + 1)


n = int(input())
magnet = [int(input()) for _ in range(n)]
count = 1
for i in range(n - 1):
	if magnet[i] != magnet[i + 1]:
		count += 1
print(count)


n = int(input())
c = v = 0
for i in ' ' * n:
	s = input()
	c += s != v
	v = s
print(c)


n = int(input())
check = 0
count = 1
for i in range(n):
	mag = int(input())
	if i == 0:
		check = mag
	if mag != check:
		count += 1
		check = mag
print(str(count))


n = int(input())
elemento1 = input()
grupo = 1
for i in range(n - 1):
	elemento2 = input()
	if elemento1 != elemento2:
		grupo += 1
	elemento1 = elemento2
print(grupo)


n = int(input())
groups = 1
magnet = input()
prev = magnet
n -= 1
while n > 0:
	n -= 1
	magnet = input()
	if magnet == prev:
		continue
	else:
		groups += 1
	prev = magnet
print(groups)


n = int(input())
part = 0
s2 = input()
for i in range(n - 1):
	s1 = s2
	s2 = input()
	if s1[1] == s2[0]:
		part += 1
print(part + 1)


n = int(input())
l = []
count = 0
for i in range(n):
	l.append(int(input()))
for i in range(n):
	if i == n - 1:
		break
	if l[i] != l[i + 1]:
		count += 1
print(count + 1)


steps = int(input())
prev = input()
num = 1
for i in range(1, steps):
	cur = input()
	if prev[1] == cur[0]:
		num += 1
	prev = cur
print(num)


n = int(input())
a = []
for i in range(n):
	b = int(input())
	a.append(b)
t = a[0]
m = 1
for i in range(1, n):
	if a[i] == t:
		continue
	else:
		m = m + 1
		t = a[i]
print(m)


a = 0
s = ''
for i in range(int(input())):
	l = input()
	if l != s:
		s = l
		a = a + 1
print(a)


n = int(input())
os = 1
pr = int(input())
for i in range(1, n):
	tek = int(input())
	if tek != pr:
		os += 1
	pr = tek
print(os)


def __starting_point():
	N = int(input())
	ans = 0
	last = ''
	while N > 0:
		inp = input()
		if inp != last:
			ans += 1
		last = inp
		N -= 1
	print(ans)
__starting_point()


a = input()
a = int(a)
s = ''
n = 0
for i in range(a):
	b = input()
	if s == '':
		s = b
	elif s[1] == b[0]:
		n += 1
	else:
		n = n
	s = b
print(n + 1)


n = int(input())
c = 0
p = 0
for i in ' ' * n:
	s = input()
	c += s != p
	p = s
print(c)


imanes = int(input(''))
lista = []
for i in range(imanes):
	lista.append(int(input()))
espacios = 1
for i in range(imanes - 1):
	if lista[i] - lista[i + 1] != 0:
		espacios += 1
print(espacios)


groups = 1
n = int(input())
previous_magnet = input()
for _ in range(n - 1):
	current_magnet = input()
	if previous_magnet != current_magnet:
		groups += 1
	previous_magnet = current_magnet
print(groups)


n = int(input())
counter = 1
l = []
for i in range(n):
	l.append(int(input()))
for i in range(len(l) - 1):
	if l[i + 1] != l[i]:
		counter += 1
print(counter)


n = int(input())
groups = 0
current = input()
for i in range(n - 1):
	magnet = input()
	if current != magnet:
		groups += 1
	current = magnet
print(groups + 1)


x = int(input())
z = int(input())
d = 1
for i in range(1, x):
	f = int(input())
	if z != f:
		d += 1
	z = f
print(d)


n = int(input())
groups = 0
last = ''
for i in range(0, n):
	magnet = input()
	if not magnet == last:
		groups += 1
		last = magnet
print(groups)


n = int(input())
pole = 0
last = -1
for i in range(n):
	x = input()
	if i == 0:
		last = x[1]
		pole += 1
	elif x[0] != last:
		continue
	else:
		pole += 1
		last = x[1]
print(pole)


def lay_groups(dominoes):
	last = '2'
	groups = 1
	for dom in dominoes:
		if dom[0] == last:
			groups += 1
		last = dom[1]
	print(groups)
vezes = input()
dominoes = []
for v in range(0, int(vezes)):
	item = input()
	dominoes.append(item)
lay_groups(dominoes)


n = int(input())
count = 1
x = []
for i in range(n):
	x.append(input())
curr = x[0]
for i in range(1, len(x)):
	if x[i] != curr:
		curr = x[i]
		count += 1
print(count)


n = int(input())
a = ''
for i in range(n):
	a += input()
sum = 0
for i in range(len(a) - 1):
	if '11' in a[i:i + 2] or '00' in a[i:i + 2]:
		sum += 1
print(sum + 1)


n = int(input())
(r, g) = ([], 0)
for _ in range(n):
	r.append(int(input()))
for i in range(len(r) - 1):
	if r[i] != r[i + 1]:
		g += 1
print(g + 1)


def main():
	n = int(input())
	if n == 0:
		print(0)
	prev = input()
	groups = 1
	for _ in range(n - 1):
		current = input()
		if prev[-1] == current[0]:
			groups += 1
		prev = current
	print(groups)
main()


t = int(input())
c = [4]
k = 0
for i in range(t):
	N = list(str(input()))
	if N[0] != c[0]:
		k = k + 1
	c[0] = N[0]
print(k)


n = int(input())
A = []
for i in range(n):
	A.append(input())
s = A[0]
t = 1
for x in A:
	if x == s:
		pass
	else:
		t += 1
		s = x
print(t)


n = int(input())
(prev_magnet, islands) = (input(), 1)
for _ in range(n - 1):
	magnet = input()
	if prev_magnet[1] == magnet[0]:
		islands += 1
	prev_magnet = magnet
print(islands)


N = int(input())
count = 1
previous = input()
for i in range(N - 1):
	current = input()
	if current != previous:
		count += 1
		previous = current
print(count)


n = int(input())
s = 1
curr = 0
count = 0
while s <= n:
	mg = int(input())
	if mg != curr:
		count += 1
	curr = mg
	s += 1
print(count)


n = int(input())
li = []
for _ in range(n):
	x = input()
	li.append(x)
count = 0
i = 0
while i < len(li) - 1:
	if li[i] != li[i + 1]:
		count += 1
		i += 1
	else:
		i += 1
print(count + 1)


n = int(input())
a = []
result = 1
for i in range(n):
	a.append(list(map(int, input())))
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		result += 1
print(result)


n = int(input())
prev = None
ans = 0
for j in range(n):
	i = input()
	if prev is None:
		prev = i
	if i == prev:
		continue
	else:
		prev = i
		ans += 1
print(ans + 1)


n = int(input(''))
count = 1
l = list()
for i in range(n):
	s = input('')
	l.append(s)
for i in range(len(l) - 1):
	if l[i] == '10' and l[i + 1] == '01':
		count += 1
	if l[i] == '01' and l[i + 1] == '10':
		count += 1
print(count)


n = int(input())
groups = 1
last = input()
for i in range(0, n - 1):
	m = input()
	if m != last:
		groups += 1
	last = m
print(groups)


ans = 1
n = int(input())
temp = int(input())
prev = temp
for i in range(n - 1):
	temp = int(input())
	if temp != prev:
		ans += 1
	prev = temp
print(ans, end='')


n = int(input())
mylist = []
count = 0
for _ in range(n):
	mylist.append(input())
for (i, j) in enumerate(mylist[:-1]):
	if j == mylist[i + 1]:
		continue
	else:
		count += 1
print(count + 1)


n = int(input())
p = 1
q = ''
for i in range(n):
	q += input()
for i in range(1, len(q)):
	if q[i] == q[i - 1]:
		p += 1
print(p)


n = int(input())
tmp = input()
count = 1
for i in range(1, n):
	a = input()
	count += 0 if a == tmp else 1
	tmp = a
print(count)


n = int(input())
groups_count = 1
stack = [input()]
for magnet in range(n - 1):
	pole = input()
	if stack[-1][1] == pole[0]:
		stack = [pole]
		groups_count += 1
	else:
		stack.append(pole)
print(groups_count)


def magnets(l):
	groups = 1
	for i in range(0, len(l) - 1):
		if l[i][1] == l[i + 1][0]:
			groups += 1
		else:
			groups += 0
	return groups
n = int(input())
l = []
for i in range(0, n):
	a = input()
	l.append(a)
print(magnets(l))


n = int(input())
(vls, cnt) = ([], 1)
for i in range(n):
	s = input()
	vls.append(s)
for i in range(n - 1):
	if vls[i][1] == vls[i + 1][0]:
		cnt += 1
if n == 1:
	print(1)
else:
	print(cnt)


import sys
input = sys.stdin.readline
answer = 0
previous = 0
for t in range(int(input())):
	value = input()
	if value != previous:
		answer += 1
	previous = value
print(answer)


arr = []
for _ in range(int(input())):
	arr.append(input())
count = 0
for i in range(len(arr) - 1):
	if arr[i] != arr[i + 1]:
		count += 1
print(count + 1)


n = input()
cnt = 0
st = ''
for i in range(int(n)):
	i = input()
	if i != st:
		cnt += 1
		st = i
print(cnt)


a = int(input())
c = ''
for k in range(a):
	b = input()
	c += b
sum = 1
f = c[0]
for k in range(len(c) - 1):
	if c[k + 1] == f:
		sum += 1
	f = c[k + 1]
print(sum)


n = int(input())
ans = 1
prev = input()
for i in range(1, n):
	s = input()
	if s != prev:
		ans += 1
	prev = s
print(ans)


n = int(input())
magnets = []
cnt = 0
while n > 0:
	magnets.append(input())
	n -= 1
for i in range(len(magnets) - 1):
	if magnets[i] != magnets[i + 1]:
		cnt += 1
	else:
		pass
print(cnt + 1)


magnet_list = []
numb_magnets = int(input())
count = 1
for j in range(numb_magnets):
	charge = int(input())
	magnet_list.append(charge)
for yo in range(len(magnet_list)):
	if yo == 0:
		continue
	if magnet_list[yo - 1] != magnet_list[yo]:
		count += 1
print(count)


num = int(input())
a = []
group = 1
for i in range(num):
	mag = input()
	a.append(mag)
for i in range(1, num):
	if a[i - 1] != a[i]:
		group += 1
print(group)


n = int(input())
l = []
for i in range(n):
	l.append(input())
x = l[0]
l1 = []
a = 1
for i in range(1, n):
	if l[i] == x:
		a += 1
	else:
		l1.append(a)
		a = 1
	x = l[i]
l1.append(a)
print(len(l1))


n = int(input())
b = []
count = 1
for i in range(n):
	a = int(input())
	b.append(a)
x = b[0]
for i in range(len(b)):
	if x == b[i]:
		continue
	else:
		count = count + 1
	x = b[i]
print(count)


n = int(input())
t = []
for i in range(n):
	m = int(input())
	t.append(str(m))
p = 1
for i in range(0, n - 1):
	if t[i] != t[i + 1]:
		p = p + 1
print(p)


n = int(input())
t = []
for i in range(n):
	t.append(input())
ch = ''.join(t)
print(ch.count('11') + ch.count('00') + 1)


n = int(input())
if n == 1:
	s = input()
	print('1')
elif n == 2:
	s = input()
	s1 = input()
	if s[1] != s1[0]:
		print('1')
	else:
		print('2')
else:
	s = input()
	s1 = input()
	m = 1
	for i in range(0, n - 2 + 1):
		if s[1] == s1[0]:
			m += 1
		s = s1
		if i < n - 2:
			s1 = input()
	print(m)


import math
import os
import random
import re
from sys import stdin, stdout
from collections import Counter
from itertools import permutations

def si():
	return str(stdin.readline())

def ii():
	return int(stdin.readline())

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

def li():
	return list(mi())

def debug(x):
	return stdout.write(str(x))
n = ii()
c = 0
arr = []
for i in range(n):
	x = ii()
	arr.append(x)
for i in range(n - 1):
	if arr[i] != arr[i + 1]:
		c += 1
ans = c + 1
debug(ans)


n = int(input())
count = 0
current = 0
while n > 0:
	stat = int(input())
	if current != stat:
		count += 1
		current = stat
	n -= 1
print(count)


i = int(input())
s = input()[1]
g = 1
for _ in range(i - 1):
	a = input()
	if a[0] == s:
		s = a[1]
		g += 1
print(g)


count = int(input())
value = str(input())
count_value = 0
for i in range(1, count):
	value_next = str(input())
	if int(value_next[0]) == int(value[1]):
		count_value += 1
	value = value_next
print(count_value + 1)


def magnets(lista):
	counter = 1
	for i in range(len(lista)):
		if i == len(lista) - 1:
			break
		if lista[i + 1][0] == lista[i][-1]:
			counter += 1
	return counter
inp = int(input())
lista = []
for i in range(0, inp):
	x = input()
	lista.append(x)
print(magnets(lista))


tc = int(input())
count = 1
f = 0
for _ in range(tc):
	magnet = input()
	if f and magnet[0] == prev[-1]:
		count += 1
	prev = magnet
	f = 1
print(count)


import math as mt
import sys as sy

class abc:

	def mkl(self):
		n = int(input())
		a = []
		for i in range(n):
			a.append(input())
		b = 0
		c = 0
		for i in range(len(a)):
			if b != a[i]:
				c += 1
				b = a[i]
		print(c)
b = abc()
b.mkl()


n = int(input())
prev = None
cnt = 0
for i in range(n):
	a = input()
	if a == prev:
		continue
	else:
		prev = a
		cnt += 1
print(cnt)


n = int(input())
l = input()
c = 1
for i in range(1, n):
	m = input()
	if c % 2 == 1 and m != l:
		c += 1
	elif c % 2 == 0 and m == l:
		c += 1
print(c)


n = int(input())
c = ''
for i in range(n):
	a = input()
	c = c + a
b = c.count('00')
c = c.count('11')
print(b + c + 1)


x = int(input())
l = []
c = 1
for i in range(0, x):
	y = input()
	l.append(y)
for i in range(0, x - 1):
	if l[i] == l[i + 1][::-1]:
		c = c + 1
print(c)


kol_mag = int(input())
mas = []
ostr = 1
for i in range(kol_mag):
	polis = int(input())
	mas.append(polis)
for i in range(1, kol_mag):
	if mas[i - 1] != mas[i]:
		ostr = ostr + 1
print(ostr)


n = int(input())
m0 = int(input())
c = 0
for i in range(n - 1):
	m = int(input())
	if m != m0:
		c += 1
	m0 = m
print(c + 1)


magnets_num = int(input(''))
previous_magnet = '--'
groups = 1
for i in range(magnets_num):
	magnet = input('')
	if magnet[0] == previous_magnet[-1]:
		groups += 1
		previous_magnet = magnet
	else:
		previous_magnet = magnet
print(groups)


n = int(input())
s = list()
cnt = 0
for i in range(1, n + 1):
	a = input()
	s.append(a)
for j in range(0, len(s) - 1):
	if s[j] != s[j + 1]:
		cnt += 1
print(cnt + 1)


import sys
n = int(input())
s = sys.stdin.readlines()
cnt = 1
for i in range(n - 1):
	if s[i] != s[i + 1]:
		cnt += 1
print(cnt)


from math import *

def main():
	n = int(input())
	ans = 0
	c = ''
	for _ in range(n):
		s = input()
		if s[-1] != c:
			ans += 1
		c = s[-1]
	print(ans)
main()


l = []
t = int(input())
for i in range(t):
	n = int(input())
	l.append(n)
c = 1
for i in range(t - 1):
	if l[i] == 10 and l[i + 1] == 1:
		c += 1
	elif l[i] == 1 and l[i + 1] == 10:
		c += 1
print(c)


n = int(input())
s = []
c = 1
for i in range(n):
	s.extend(list(input()))
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		c += 1
print(c)


n = int(input())
c = 1
prev = str(input())
for i in range(1, n):
	x = str(input())
	if prev[-1] == x[0]:
		c += 1
	prev = x
print(c)


n = int(input())
ls = ''.join([input() for i in range(n)])
print(ls.count('00') + ls.count('11') + 1)


n = int(input())
w = ''
for i in range(n):
	mag = input()
	w += mag
print(w.count('11') + w.count('00') + 1)


import os
import sys
from io import BytesIO, IOBase
import math
import collections

def main():
	n = int(input())
	ans = 1
	for i in range(n):
		s = input()
		if i == 0:
			prev = s[1]
			continue
		if s[0] == prev:
			ans += 1
		prev = s[1]
	print(ans)
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')
main()


z = int(input())
arr = []
for i in range(z):
	arr.append(int(input()))
ans = 1
for i in range(z - 1):
	if arr[i] != arr[i + 1]:
		ans += 1
print(ans)


n = int(input())
count = 0
flag = 0
while n:
	gr = int(input())
	if gr == flag:
		count += 0
	else:
		flag = gr
		count += 1
	n -= 1
print(count)


n = int(input())
count = 1
avi = []
i = 0
for i in range(n):
	avi.append(input())
j = 0
for j in range(n - 1):
	if avi[j] == '10' and avi[j + 1] == '01':
		count = count + 1
	elif avi[j] == '01' and avi[j + 1] == '10':
		count = count + 1
print(count)


def main():
	size = int(input())
	a = int(input())
	groups = 1
	for i in range(size - 1):
		b = int(input())
		if a != b:
			groups += 1
			a = b
	print(groups)
main()


n = int(input())
k = 0
for i in range(1, n + 1):
	s = input()
	if i > 1 and t == s[0]:
		k += 1
	t = s[len(s) - 1]
print(k + 1)


n = int(input())
a = []
b = []
count = 0
for i in range(n):
	s = input()
	a.append(s)
a.append(str(11))
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		continue
	else:
		count = count + 1
print(count)


n = int(input())
x = input()
answer = 0
if n == 1:
	print(1)
else:
	for i in range(n - 1):
		i = input()
		if i != x:
			answer += 1
		x = i
	answer += 1
	print(answer)


n = int(input())
arr = []
count = 0
for i in range(n):
	string = input()
	for i in string:
		arr.append(i)
for i in range(0, len(arr) - 1):
	if arr[i] == arr[i + 1]:
		count += 1
print(count + 1)


n = int(input())
l = []
x = 1
s = str(input())
l.append(s)
for i in range(1, n):
	s = str(input())
	l.append(s)
	if l[i - 1] != l[i]:
		x = x + 1
print(x)


n = int(input())
count = 1
num1 = int(input())
for i in range(0, n - 1):
	num2 = int(input())
	if num1 != num2:
		count += 1
	num1 = num2
print(count)


n = int(input())
magnets = []
for _ in range(n):
	magnet = int(input())
	magnets.append(magnet)
groups = 1
for i in range(len(magnets) - 1):
	if magnets[i] != magnets[i + 1]:
		groups += 1
print(groups)


x = input()
prev = ''
count = 1
for i in range(int(x)):
	y = input()
	if prev == '':
		prev = y
	elif prev == y:
		prev = y
	else:
		prev = y
		count = count + 1
print(count)


n = int(input())
l = []
grp = 0
for i in range(n):
	l.append(list(input()))
i = 0
k = 0
while i < n:
	ctr = l[i][-1]
	k = 0
	while i + k + 1 < n and l[i + k + 1][-1] == ctr:
		k = k + 1
	i = i + k + 1
	grp += 1
print(grp)


x = int(input())
a = []
for i in range(x):
	a.append(input())
c = 0
for j in range(1, x):
	if a[j - 1][1] == a[j][0]:
		c = c + 1
print(c + 1)


n = int(input())
curr = input()
count = 1
for i in range(1, n):
	next = input()
	if curr != next:
		curr = next
		count += 1
print(count)


val = ''
count = 0
for _ in range(int(input())):
	s = input()
	if val:
		count += 1 if val[-1] != s[-1] else 0
	else:
		count += 1
	val = s
print(count)


k = int(input())
t = 0
l = []
for i in range(k):
	l.append(int(input()))
for i in range(k - 1):
	if l[i] != l[i + 1]:
		t = t + 1
print(t + 1)


n = int(input())
line = []
for i in range(n):
	m = int(input())
	line.append(m)
if n == 1:
	print(1)
else:
	line1 = []
	for i in range(1, n):
		if line[i - 1] != line[i]:
			line1.append(i - 1)
	print(len(line1) + 1)


n = int(input())
a = []
for i in range(n):
	s = input().strip()
	a.append(s)
count = 1
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		count += 1
print(count)


n = int(input())
s = []
u = 1
s.append(input())
for i in range(1, n):
	s.append(input())
	if s[i] != s[i - 1]:
		u = u + 1
print(u)


n = int(input())
magnets = []
groups = 1
for i in range(n):
	magnets.append(input())
for j in range(n - 1):
	if not (magnets[j][1] == '0' and magnets[j + 1][0] == '1' or (magnets[j][1] == '1' and magnets[j + 1][0] == '0')):
		groups += 1
print(groups)


n = int(input())
prev_magnet = ''
new_magnet = ''
block = 1
prev_magnet = input()
for i in range(n - 1):
	new_magnet = input()
	if prev_magnet[1] == new_magnet[0]:
		block += 1
	prev_magnet = new_magnet
print(block)


def islands(number):
	lst = []
	sum_of_islands = 1
	magnet = 0
	for _value in range(number):
		magnet = int(input())
		lst.append(magnet)
	for i in range(len(lst)):
		if i <= len(lst) - 2 and lst[i] != lst[i + 1]:
			sum_of_islands += 1
	return sum_of_islands
magnets = int(input())
print(islands(magnets))


import sys
n = int(sys.stdin.readline().strip())
row = []
for i in range(n):
	m = sys.stdin.readline().strip()
	row.append(m)
count = 1
for magnet in range(n - 1):
	if row[magnet] != row[magnet + 1]:
		count = count + 1
print(count)


n = int(input())
str1 = input()
count = 1
while n - 1 > 0:
	n -= 1
	str2 = input()
	if str1 != str2:
		count += 1
		str1 = str2
print(count)


t = int(input())
mag = []
while t != 0:
	s = input()
	mag.append(s)
	t = t - 1
lstcount = 1
if t == 1:
	print(1)
else:
	for i in range(0, len(mag) - 1):
		if mag[i] != mag[i + 1]:
			lstcount = lstcount + 1
	print(lstcount)


n = int(input())
array = dict()
sum = 1
for i in range(n):
	array[i] = input()
for i in range(n):
	if i == n - 1:
		break
	if array[i] != array[i + 1]:
		sum += 1
print(sum)


q = int(input())
magnets = ''.join([input() for _ in range(q)])
result = magnets.count('11') + magnets.count('00') + 1
print(result)


n = int(input())
arr = []
c = 1
for _ in range(n):
	arr.append(int(input()))
for i in range(n - 1):
	if arr[i] != arr[i + 1]:
		c += 1
print(c)


n = int(input())
count = 1
inputs = []
for i in range(0, n):
	x = int(input())
	inputs.append(x)
first = inputs[0]
for i in range(1, len(inputs)):
	if first == inputs[i]:
		continue
	else:
		count += 1
	first = inputs[i]
print(count)


n = int(input())
key = '00'
group_count = 0
for _ in range(n):
	s = input()
	if s != key:
		group_count += 1
		key = s
print(group_count)


n = int(input())
z = []
c = 1
for i in range(n):
	z.append(int(input()))
for i in range(n - 1):
	if z[i] != z[i + 1]:
		c += 1
print(c)


n = int(input())
lst = []
cnt = 1
for a0 in range(n):
	a = int(input())
	lst.append(a)
for i in range(n - 1):
	if lst[i] != lst[i + 1]:
		cnt += 1
print(cnt)


n = int(input())
l = []
c = 0
for _ in range(n):
	x = int(input())
	l.append(x)
y = l[0]
for i in range(1, n):
	if y == l[i]:
		pass
	else:
		y = l[i]
		c = c + 1
		pass
	pass
print(c + 1)


import sys
f = sys.stdin
a = f.read().strip().split('\n')[1:]
l = len(a)
i = 1
cnt = 1
while i < l:
	if a[i - 1] != a[i]:
		cnt += 1
	i += 1
print(cnt)


n = int(input())
f = 0
a = int(input())
for i in range(n - 1):
	b = int(input())
	if a == b:
		f = f
		a = b
	else:
		f = f + 1
		a = b
print(f + 1)


a = int(input())
s = ''
for i in range(a):
	b = input()
	s += b
k = 1
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		k += 1
print(k)


foo = int(input())
arr = ''
for i in range(foo):
	arr += input()
print(arr.count('00') + arr.count('11') + 1)


n = int(input())
A = []
s = 0
for i in range(n):
	a = input()
	A.append(a[0])
	A.append(a[1])
for i in range(len(A) - 1):
	if A[i] == A[i + 1]:
		s += 1
print(s + 1)


import sys
n = int(input())
ch = sys.stdin.read()
ch = ch.split('\n')
ch = ''.join(ch)
p = ch.count('1001') + ch.count('0110') + 1
print(p)


n = int(input())
groups = 1
for i in range(n):
	line = input()
	if i > 0 and line != prev:
		groups += 1
	prev = line
print(groups)


n = int(input())
m = list()
for i in range(n):
	m += [int(input())]
count = 1
a = m[0]
for i in range(1, n):
	if a == m[i]:
		pass
	else:
		a = m[i]
		count += 1
print(count)


n = int(input())
p = ''
d = 0
for i in range(0, n):
	s = input()
	p = p + s
l = len(p)
for i in range(0, l - 1):
	if p[i] == p[i + 1]:
		d = d + 1
print(d + 1)


cases = int(input())
magnets = []
for case in range(cases):
	new_magnet = input()
	magnets.append(new_magnet)
group = 1
for i in range(len(magnets) - 1):
	m1 = magnets[i]
	m2 = magnets[i + 1]
	if m1[1] == m2[0]:
		group += 1
print(group)


n = int(input())
magnet_1 = input()
magnet_2 = 0
answer = 0
for i in range(n - 1):
	magnet_2 = input()
	if magnet_1 != magnet_2:
		answer += 1
	magnet_1 = magnet_2
print(answer + 1)


a = int(input())
c = []
for i in range(a):
	b = int(input())
	c.append(b)
j = 1
for i in range(a - 1):
	if c[i] != c[i + 1]:
		j += 1
print(j)


n = int(input())
l = []
c = 1
for i in range(n):
	m = input()
	l.append(m)
for j in range(len(l) - 1):
	if l[j] != l[j + 1]:
		c += 1
print(c)


t = int(input())
c = 1
l1 = []
while t > 0:
	l1.append(input())
	t -= 1
i = 1
while i < len(l1):
	if l1[i] != l1[i - 1]:
		c += 1
	i += 1
print(c)


ans = 0
prev = -1
for _ in range(int(input())):
	s = int(input())
	if prev == -1:
		ans += 1
		prev = s
		continue
	if s == prev:
		continue
	prev = s
	ans += 1
print(str(ans))


n = 1
m = int(input())
p = input()
for i in range(1, m):
	x = input()
	if x[-1] == p[0]:
		n += 1
	p = x
print(n)


s = ''
for i in range(int(input())):
	si = input()
	s += si
ans = 1
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		ans += 1
print(ans)


n = int(input(''))
mag = []
mis_c = 0
for i in range(n):
	s = input('')
	mag.append(s)
	if i > 0 and mag[i - 1] != s:
		mis_c += 1
print(mis_c + 1)


n = int(input())
count = 0
prev_mag = None
for i in range(n):
	mag = input()
	if prev_mag is None:
		prev_mag = mag
		continue
	elif prev_mag == mag:
		continue
	elif prev_mag != mag:
		count += 1
		prev_mag = mag
print(count + 1)


x = int(input())
z = []
for i in range(x):
	z.append(int(input()))
group = 1
for i in range(len(z) - 1):
	if z[i] != z[i + 1]:
		group = group + 1
print(group)


p = f = 0
for i in [0] * int(input()):
	s = input()
	f += p != s
	p = s
print(f)


quant = int(input())
dom = []
cont = 1
for i in range(quant):
	num = input()
	dom.append(num)
for i in range(quant):
	if i == quant - 1:
		break
	elif dom[i] == '01' and dom[i + 1] == '10':
		cont += 1
	elif dom[i] == '10' and dom[i + 1] == '01':
		cont += 1
print(cont)


n = int(input())
k = 1
l = list()
s = ''
for i in range(n):
	l.append(input())
	s += l[i]
for j in range(len(s) - 1):
	if s[j] == s[j + 1]:
		k += 1
print(k)


n = int(input())
res = ''
count = 0
for i in range(n):
	res += input()
for i in range(1, len(res) - 2, 2):
	if res[i] == res[i + 1]:
		count += 1
print(count + 1)


from sys import stdin, stdout
n = int(stdin.readline())
if n == 1:
	stdout.write(str(1))
else:
	magnets = list()
	for m in range(n):
		magnets.append(stdin.readline())
	combined_magnet = ''.join([ch.rstrip('\n') for ch in magnets])
	groups = 1
	for index in range(1, len(combined_magnet) - 1):
		if combined_magnet[index] == combined_magnet[index + 1]:
			groups += 1
	stdout.write(str(groups))


n = int(input())
groups = 1
previous = input()
n -= 1
for i in range(n):
	now = input()
	if previous != now:
		groups += 1
	previous = now
print(groups)


from sys import stdin
n = int(stdin.readline()[:-1])
groups = 1
prev = stdin.readline()[:-1]
for i in range(n - 1):
	if prev != stdin.readline()[:-1]:
		groups += 1
		prev = prev[::-1]
print(groups)


n = int(input())
mag = []
for i in range(n):
	mag.append(input())
mag = ''.join(mag)
print(1 + mag.count('00') + mag.count('11'))


def solve(magnets):
	groups = 1
	for i in range(len(magnets) - 1):
		if magnets[i] != magnets[i + 1]:
			groups += 1
	return groups
number_of_magnets = int(input())
magnets = []
for magnet in range(number_of_magnets):
	magnets.append(input())
print(solve(magnets))


magnets_num = int(input())
magnets = []
count = 1
for i in range(magnets_num):
	magnets.append(input())
for i in range(1, magnets_num):
	if magnets[i] != magnets[i - 1]:
		count += 1
	else:
		continue
print(count)


number = int(input())
ans = 1
previous = '2'
for each in range(0, number):
	magnet = input()
	if previous == magnet[0]:
		ans += 1
	previous = magnet[1]
print(ans)


(l, b) = ('', 0)
for _ in range(int(input())):
	a = input()
	b += l != a
	l = a
print(b)


inp = int(input())
magnet = ''
for x in range(inp):
	mg = str(input())
	magnet += mg
ones = magnet.count('11')
zeros = magnet.count('00')
print(ones + zeros + 1)


n = int(input())
a = []
zhi = []
for i in range(n):
	a.append(int(input()))
org = a[0]
for num in a:
	ncount = 0
	if num == org:
		ncount += 1
	else:
		zhi.append(ncount)
		ncount = 0
		org = num
print(len(zhi) + 1)


import sys
a = int(input())
d = []
e = []
c = 1
k = 1
if a == 1:
	print('1')
	sys.exit()
for i in range(0, a):
	d.append(list(map(int, input())))
for i in range(0, a - 1):
	if d[i][1] != d[i + 1][0]:
		c = c + 1
	else:
		e.append(c)
		c = 1
		k = k + 1
print(k)


n = int(input())
r = 0
d2 = 0
for i in range(n):
	d1 = int(input())
	if d1 != d2:
		r += 1
		d2 = d1
print(r)


n = int(input())
c = 1
pa = input()
for i in range(n - 1):
	pr = input()
	if pa == '10' and pr == '01':
		c += 1
	elif pa == '01' and pr == '10':
		c += 1
	pa = pr
print(c)


def fun():
	n = int(input())
	l = []
	while n > 0:
		l += map(int, input().split())
		n -= 1
	cnt = 1
	l = list(l)
	for i in range(len(l) - 1):
		if l[i] != l[i + 1]:
			cnt += 1
	print(cnt)
fun()


n = int(input())
prev = None
ans = 0
for i in range(n):
	x = input()
	if x != prev:
		ans += 1
		prev = x
print(ans)


lst = []
n = int(input())
for i in range(n):
	c = 1
	lst.append(input())
ans = 1
t = lst[0]
p = 0
for i in range(len(lst)):
	if lst[i] != lst[p]:
		ans += 1
	p = i + 0
print(ans)


a = int(input())
pre = -1
ans = 0
for i in range(a):
	x = input()
	if x != pre:
		ans += 1
	pre = x
print(ans)


n = int(input())
l = []
c = 0
for i in range(0, n):
	k = int(input())
	l.append(k)
for i in range(len(l)):
	if i == len(l) - 1:
		break
	if l[i] != l[i + 1]:
		c += 1
	else:
		continue
print(c + 1)


n = int(input())
l = [input() for i in range(n)]
a = 1
for i in range(n - 1):
	if l[i + 1] != l[i]:
		a += 1
print(a)


n = int(input())
curr = input()
den = 1
for _ in range(n - 1):
	nxt = input()
	if nxt != curr:
		den += 1
	curr = nxt
print(den)


n = int(input())
ar = []
s = 1
for i in range(0, n):
	x = input()
	ar.append(x)
for i in range(0, n - 1):
	if ar[i] == '10':
		if ar[i + 1] != '10':
			s = s + 1
	elif ar[i + 1] != '01':
		s = s + 1
print(s)


n = int(input())
magnit = ''
island = 0
for i in range(n):
	s = input()
	if magnit != s:
		island += 1
		magnit = s
print(island)


n = int(input())
l = ''
for i in range(n):
	l += input()
c = 0
i = 0
while i < len(l) - 1:
	if l[i] == l[i + 1]:
		c += 1
	i += 1
print(c + 1, end='')


t = int(input())
a = []
for i in range(0, t):
	a.append(int(input()))
count = 1
s = a[0]
for i in range(0, len(a)):
	if a[i] != s:
		count = count + 1
		s = a[i]
print(count)


n = int(input())
h = input()
g = h
cnt = 1
for i in range(n - 1):
	h = input()
	if g == h:
		pass
	else:
		cnt += 1
		g = h
print(cnt)


n = input('')
i = 0
flag = 0
c = 1
while i < int(n):
	s = input('')
	if i == 0:
		flag = s[0]
	elif flag == '0' and s[0] == '1':
		c = c + 1
		flag = '1'
	elif flag == '1' and s[0] == '0':
		c = c + 1
		flag = '0'
	i = i + 1
print(c)


n = int(input())
r1 = j = 0
p = []
l = str(input())
p.append(l)
for i in range(1, n):
	k = str(input())
	if p[j] != k:
		r1 = r1 + 1
	p.append(k)
	j = j + 1
print(r1 + 1)


n = int(input())
l = []
for i in range(n):
	l.append(input())
result = 1
is_10 = l[0] == '10'
for i in range(1, n):
	if is_10:
		if l[i] != '10':
			result += 1
			is_10 = False
	elif l[i] != '01':
		result += 1
		is_10 = True
print(result)


x = int(input())
arr = []
for i in range(x):
	s = int(input())
	arr.append(s)
c = 0
for l in range(x - 1):
	if arr[l] != arr[l + 1]:
		c += 1
print(c + 1)


n = int(input())
k = 1
w = input()
for i in range(n - 1):
	t = input()
	k = k + 1 if t != w else k
	w = t
print(k)


y = int(input())
k = []
b = []
res = 1
for i in range(y):
	z = int(input())
	k.append(z)
if y == 1:
	print(1)
else:
	for i in range(1, y):
		if k[i] != k[i - 1]:
			res += 1
	print(res)


n = int(input())
previous = int(input())
k = 0
while n > 1:
	a = int(input())
	if a != previous:
		k += 1
	previous = a
	n = n - 1
print(k + 1)


def magnet_judge(listx, n):
	return 1 if listx[n] == listx[n + 1] else 0
list1 = []
for i in range(int(input())):
	list1.append(input())
list2 = [magnet_judge(list1, n) for n in range(len(list1) - 1)]
print(list2.count(0) + 1)


n = int(input())
gr = 1
l = []
for i in range(n):
	l.append(input())
for i in range(n - 1):
	if l[i][1] != l[i + 1][0]:
		gr = gr
	else:
		gr = gr + 1
print(gr)


n = int(input())
w = [input() for i in range(n)]
x = 0
for j in range(n - 1):
	if w[j] != w[j + 1]:
		x += 1
print(x + 1)


n = int(input())
arr = [0] * n
result = 0
for i in range(n):
	arr[i] = int(input())
for j in range(1, n):
	if arr[j] != arr[j - 1]:
		result += 1
print(result + 1)


n = input()
a = []
r = 0
for i in range(0, int(n)):
	j = input()
	a.append(j)
if len(a) == 1:
	print('1')
elif len(a) == 0:
	print('0')
else:
	r = 1
	for i in range(1, len(a)):
		if a[i] != a[i - 1]:
			r = r + 1
	print(r)


n = int(input())
j = 0
c = 0
for _ in range(n):
	a = input()
	if j != a:
		c = c + 1
		j = a
	else:
		j = a
print(c)


def func(n):
	l1 = [x for k in [list(map(int, i)) for i in [input() for _ in range(n)]] for x in k]
	breaks = 0
	for i in range(len(l1) - 1):
		if l1[i] != l1[i + 1]:
			continue
		else:
			breaks += 1
	return breaks + 1
print(func(int(input())))


N = input()
magnet = []
for i in range(int(N)):
	x = input()
	magnet.append(x)
for i in range(len(magnet) - 1):
	if magnet[i][1] == magnet[i + 1][0]:
		magnet[i] = magnet[i] + '_'
a = ''.join(magnet)
res = a.split('_')
ans = len(res)
print(ans)


n = int(input())
last_magnet = ''
count = 0
for i in range(n):
	magnet = input()
	if magnet != last_magnet:
		count += 1
	last_magnet = magnet
print(count)


t = int(input())
s = input()
ans = 1
for _ in range(t - 1):
	i = input()
	if i != s:
		ans += 1
		s = i
print(ans)


n = int(input())
t = ''
for i in range(0, n):
	s = input()
	t = t + s
cnt = 1
for j in range(1, len(t) - 2, 2):
	if t[j] == t[j + 1]:
		cnt = cnt + 1
print(cnt)


n = int(input())
a = []
b = 0
for i in range(n):
	x = input()
	a.append(x)
for i in range(n):
	if i != n - 1:
		if (a[i] == '10') & (a[i + 1] == '01'):
			b += 1
		if (a[i] == '01') & (a[i + 1] == '10'):
			b += 1
print(b + 1)


len1 = int(input())
count = 1
last = input()
for i in range(len1 - 1):
	b = input()
	if b != last:
		count += 1
	last = b
print(count)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
count = 1
for i in range(n):
	try:
		if l[i] == l[i + 1]:
			continue
		elif l[i] != l[i + 1]:
			count += 1
	except:
		continue
print(count)


import sys
n = int(sys.stdin.readline())
res = 0
d = 0
t = 0
for i in range(n):
	d = int(sys.stdin.readline())
	if t != d:
		res += 1
		t = d
print(res)


n = int(input())
c = 0
tmp = 0
for i in range(n):
	x = int(input())
	if x != tmp:
		c = c + 1
	tmp = x
print(c)


x = int(input())
a = []
a.append(input())
i = 1
k = 1
while i < x:
	a.append(input())
	if a[i - 1] != a[i]:
		k += 1
	i += 1
print(k)


n = int(input())
magnets = []
for i in range(n):
	magnets.append(int(input()))
count = 1
for j in range(len(magnets) - 1):
	if magnets[j] == magnets[j + 1]:
		count += 0
	else:
		count += 1
print(count)


n = int(input())
p = 0
l = ''
for x in range(0, n):
	c = input()
	if c != l:
		p = p + 1
	l = c
print(p)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
c = 0
g = 0
for i in range(n - 1):
	if l[i] != l[i + 1]:
		c += 1
		g = g + 1
print(g + 1)


n = int(input())
pos_l = []
x = 1
for i in range(n):
	pos = input()
	pos_l.append(pos)
	if i > 0:
		if pos_l[i][0] == pos_l[i - 1][1]:
			x += 1
print(x)


def main():
	n = int(input())
	l = []
	magnet = ''
	for i in range(n):
		s = input()
		if len(magnet) == 0:
			magnet += s
		elif magnet[-1] != s[0]:
			magnet += s
		elif magnet[-1] == s[0]:
			l.append(magnet)
			magnet = s
	l.append(magnet)
	print(len(l))
main()


import sys
input = sys.stdin.readline
n = int(input())
pre = int(input())
groups = 1
for i in range(1, n):
	nextmagnet = int(input())
	if pre != nextmagnet:
		groups += 1
		pre = nextmagnet
print(groups)


n = int(input())
p = []
groups = 1
for i in range(n):
	p.append(int(input()))
	if p[i] != p[i - 1]:
		groups += 1
	else:
		pass
print(groups)


k = int(input())
l = []
c = 1
for i in range(k):
	l.append(input())
	if i > 0:
		if l[1] != l[0]:
			c += 1
		l.pop(0)
print(c)


num_magnets = int(input())
list_magnets = []
for i in range(num_magnets):
	list_magnets.append(input())
group = 1
for i in range(num_magnets - 1):
	if list_magnets[i] != list_magnets[i + 1]:
		group += 1
print(group)


n = int(input())
group = 1
seq = []
for i in range(n):
	seq.append(str(input()))
for i in range(n - 1):
	back = seq[i][1]
	front = seq[i + 1][0]
	if back == front:
		group += 1
print(group)


count = 0
prev = ''
for _ in range(int(input())):
	mg = input()
	if mg != prev:
		count += 1
	prev = mg
print(count)


n = int(input())
l = []
for i in range(n):
	l.append(input())
s = ''.join(l)
a = s.count('00')
b = s.count('11')
print(a + b + 1)


n = int(input())
count1 = 0
a = 0
for i in range(n):
	f = a
	a = input()
	if a != f:
		count1 += 1
print(count1)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
import statistics
from statistics import mode
from functools import reduce
mod = 1000000007

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

def out(var):
	sys.stdout.write(str(var))

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

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def most_frequent(List):
	occurence_count = Counter(List)
	return occurence_count.most_common(1)[0][0]

def most_common(List):
	return mode(List)

def chinese_remainder(a, p):
	prod = reduce(op.mul, p, 1)
	x = [prod // pi for pi in p]
	return sum((a[i] * pow(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a)))) % prod

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3

def memoized(*args):
	if args in stored_results:
		return stored_results[args]
	else:
		result = stored_results[args] = fn(*args)
		return result
	return memoized
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e
a = [input() for _ in range(int(input()))]
b = 1
a = ''.join(map(str, a))
i = 0
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		b += 1
	else:
		continue
print(b)
import operator
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e


total = int(input())

def group():
	first = input()
	group = 1
	if total > 1:
		for x in range(total - 1):
			poles = input()
			group += 1 if first != poles else 0
			first = poles
	return group
print(group())


x = int(input())
L = []
count = 1
for i in range(x):
	L.append(input())
for i in range(x - 1):
	if L[i][1] == L[i + 1][0]:
		count += 1
print(count)


a = int(input())
c = input()
ans = 1
for i in range(a - 1):
	b = input()
	if b != c:
		ans += 1
		c = b
print(ans)


n = int(input())
groups = 1
prev = input()
for _ in range(n - 1):
	current = input()
	if current != prev:
		groups += 1
	prev = current
print(groups)


n_magnets = int(input())
magnets = [int(input()) for i in range(n_magnets)]
if n_magnets == 1:
	print(1)
else:
	n_groups = 1
	mag_gen = (mag for mag in magnets)
	a = next(mag_gen)
	for i in range(n_magnets - 1):
		b = next(mag_gen)
		if a != b:
			n_groups += 1
		a = b
	print(n_groups)


n = int(input())
ar = []
group = 1
for i in range(n):
	l = int(input())
	ar.append(l)
for i in range(1, len(ar)):
	if ar[i - 1] != ar[i]:
		group += 1
print(group)


from sys import stdin
n = int(input())
count = 1
old_q = stdin.readline()
for i in range(n - 1):
	q = stdin.readline()
	if old_q[1] == q[0]:
		count += 1
	old_q = q
print(count)


import sys
n = int(input())
step = 0
magnets = 1
result = 0
while n > 0:
	domino = str(input())
	if step == 0:
		end = int(domino[1])
		step = 1
	else:
		start = int(domino[0])
		if end == start:
			magnets += 1
		end = int(domino[1])
	n -= 1
print(magnets)


def main():
	from sys import stdout
	n = int(input())
	current = ''
	res = 0
	for i in range(n):
		new = input()
		if new != current:
			current = new
			res += 1
	stdout.write(str(res))
main()


from sys import *
n = int(stdin.readline())
g = 0
d = '11'
for i in range(n):
	x = stdin.readline()
	if d != x:
		g += 1
	d = x
print(g)


n = int(input())
po = []
count = 0
for i in range(0, n):
	p = input()
	po.append(p)
for j in range(0, n - 1):
	if po[j][1] == po[j + 1][0]:
		count = count + 1
	else:
		pass
print(count + 1)


n = int(input())
ans = 0
prev = ''
for i in range(n):
	s = input()
	if i == 0:
		ans += 1
		if s == '01':
			prev = 'minus'
		else:
			prev = 'plus'
	elif s == '01' and prev == 'minus':
		continue
	elif s == '01' and prev == 'plus':
		ans += 1
		prev = 'minus'
	elif s == '10' and prev == 'minus':
		ans += 1
		prev = 'plus'
	else:
		continue
print(ans)


n = int(input())
grp = 0
temp = 0
for i in range(n):
	a = int(input())
	if temp != a:
		grp += 1
		temp = a
print(grp)


n = int(input())
m = 0
a = []
c = 0
k = 0
while n > 0:
	n = n - 1
	x = input()
	a.append(x)
for i in range(1, len(a)):
	if a[i - 1] == a[i]:
		c = c + 1
	else:
		k = k + 1
	if m < c:
		m = c
print(k + 1)


try:
	n = int(input())
	count = 1
	for i in range(n):
		s = str(input())
		if i >= 1:
			if temp == s[0]:
				count += 1
		temp = s[1]
	print(count)
except:
	pass


banyak_magnet = int(input())
kelompok_magnet = 1
n = str()
for i in range(banyak_magnet):
	c = str(input())
	if i == 0:
		n = c[0]
	elif i >= 1:
		if c[1] == n:
			kelompok_magnet += 1
			n = c[0]
print(kelompok_magnet)


n = int(input())
list1 = []
cou = 1
for i in range(n):
	list1.append(input())
for i in range(len(list1) - 1):
	if list1[i][1] == list1[i + 1][0]:
		cou += 1
print(cou)


n = int(input())
cur = input()
cnt = 1
for i in range(n - 1):
	temp = input()
	if cur != temp:
		cnt += 1
	cur = temp
print(cnt)


a = int(input())
res = 0
point = str()
for i in range(a):
	s = input()
	if s != point:
		res += 1
		point = str(s)
print(res)


n = int(input())
arr = list()
for i in range(n):
	arr.append(input())
res = 1
for i in range(n - 1):
	if arr[i] != arr[i + 1]:
		res += 1
print(res)


try:
	l = int(input())
	a = b = 0
	for i in ' ' * l:
		n = input()
		b += a != n
		a = n
	print(b)
except:
	pass


import sys
n = int(sys.stdin.readline())
groups = 1
prev = None
for line in map(str.rstrip, sys.stdin):
	if prev is None:
		prev = line
	elif prev != line:
		groups += 1
		prev = line
print(str(groups))


n = int(input())
l = []
for i in range(n):
	l.append(input())
count = 1
for i in range(len(l)):
	if i != len(l) - 1 and l[i] != l[i + 1]:
		count += 1
	else:
		continue
print(count)


from sys import stdin, stdout
(inp, c) = ([int(str(x).rstrip()) for x in stdin.readlines()], 1)
for i in range(1, inp[0]):
	if inp[i] != inp[i + 1]:
		c += 1
print(c)


i = input
c = 1
n = int(i())
s = i()
for j in range(n - 1):
	s2 = i()
	if s[1] != s2[0]:
		s = s2
	else:
		c += 1
		s = s2
print(c)


n = int(input())
g = 0
prev = '-1'
l = []
for i in range(0, n):
	l.append(input())
	if i == 0:
		prev = l[0][-1]
	elif l[i][0] != prev:
		prev = l[i][-1]
		continue
	else:
		g += 1
		prev = l[i][-1]
print(g + 1)


n = int(input())
l = []
for x in range(n):
	l.append(int(input()))
c = l[0]
cc = False
g = 1
for x in range(n - 1):
	if c != l[x + 1]:
		g += 1
		c = l[x + 1]
	cc = True
print(g)
exit()


magnets = int(input())
count = 1
st_1 = input()
List_1 = [st_1[0], st_1[1]]
for magnet in range(magnets - 1):
	List = []
	st = input()
	for i in range(2):
		List.append(st[i])
	if List[0] != List_1[0]:
		count += 1
		List_1 = List[:]
print(count)


n = int(input())
(c, s) = (0, 1)
for i in range(n):
	m = input()
	if i < 1:
		c = m
	elif c != m:
		s += 1
		c = m
print(s)


n_of_magnets = input()
last_magnet = input()
n_of_groups = 1
for i in range(int(n_of_magnets) - 1):
	current = input()
	if current != last_magnet:
		n_of_groups += 1
	last_magnet = current
print(n_of_groups)


def magnets():
	no_of_lines = int(input())
	l = list()
	for i in range(no_of_lines):
		l.append(input())
	counter = 1
	i = 0
	while i < len(l) - 1:
		if l[i] != l[i + 1]:
			counter += 1
		i += 1
	print(counter)
magnets()


n = int(input())
mag = []
for i in range(0, n):
	mag.append(int(input()))
c = 1
prev = mag[0]
for i in range(1, n):
	if prev != mag[i]:
		c = c + 1
		prev = mag[i]
print(c)


a = []
for i in range(int(input())):
	a.append(int(input()))
print(sum([abs(a[i + 1] - a[i]) for i in range(len(a) - 1)]) // 9 + 1)


def magnets(lis):
	counter = 0
	current = lis[0]
	for x in lis[1:]:
		if x == '10' and current == '01' or (x == '01' and current == '10'):
			counter += 1
		current = x
	return counter + 1
i = int(input())
l = []
for x in range(i):
	l.append(input())
print(magnets(l))


def solve():
	N = int(input())
	G = 0
	prev = int(input())
	for i in range(1, N):
		curr = int(input())
		if curr != prev:
			G += 1
		prev = curr
	return G + 1
ans = solve()
print(ans)


n = int(input())
ai = input()
b = 1
for i in range(1, n):
	aj = input()
	if ai != aj:
		b += 1
	ai = aj
print(b)


n = int(input())
b = []
count = 1
for i in range(n):
	x = int(input())
	b.append(x)
for i in range(len(b) - 1):
	if b[i] == b[i + 1]:
		count == count
	else:
		count += 1
print(count)


n = int(input())
_c = 1
a = False
for i in range(n):
	c = int(input())
	if a and c != a:
		_c += 1
	a = c
print(_c)


n = int(input())
s = ''
for i in range(n):
	s += input()
print(len(s.replace('11', '1 1').replace('00', '0 0').split()))


n = int(input())
mp = input()
g = 1
for i in range(0, n - 1):
	mc = input()
	if mc != mp:
		g += 1
	mp = mc
print(g)


k = int(input())
str = ''
for _ in range(k):
	l = input()
	if l == '10':
		str += 'a'
	else:
		str += 'b'
c = 1
for i in range(len(str) - 1):
	if str[i + 1] != str[i]:
		c += 1
print(c)


qtd = int(input())
atual = ''
grupo = 0
for _ in range(qtd):
	novo = input()
	if novo != atual:
		grupo += 1
	atual = novo
print(grupo)


n = int(input())
l = []
p = []
c = 1
for i in range(0, n):
	l.append(input().split())
	m = int(l[i][0])
	p.append(m)
for i in range(0, n - 1):
	if p[i] != p[i + 1]:
		c = c + 1
print(c)


a = int(input())
b = []
count = 1
for i in range(a):
	b.append(int(input()))
for i in range(1, len(b)):
	if b[i - 1] != b[i]:
		count = count + 1
print(count)


s = ''
cnt = 1
for n in range(int(input().strip())):
	s += input().strip()
cnt += s.count('00') + s.count('11')
print(cnt)


n = int(input())
magnets = []
count = 1
for i in range(0, n):
	x = str(input())
	magnets.append(x)
for a in range(0, len(magnets) - 1):
	if magnets[a] != magnets[a + 1]:
		count = count + 1
print(count)


while 1:
	try:
		n = int(input())
		a = []
		for i in range(0, n):
			b = input()
			a.append(b)
		count = 1
		for i in range(1, n - 1):
			if a[i] == a[i - 1]:
				continue
			if a[i + 1] == a[i - 1] and a[i - 1] != a[i]:
				count += 1
			else:
				count += 1
		if a[n - 1] != a[n - 2]:
			count += 1
		print(count)
	except EOFError:
		break


z = int(input())
c = 0
t = 0
for i in range(z):
	u = int(input())
	if u != t:
		c += 1
	t = u
print(c)


n = int(input())
list1 = []
for _ in range(n):
	list1.append(int(input()))
count = 0
for x in range(n - 1):
	if list1[x] == list1[x + 1]:
		continue
	else:
		count += 1
count += 1
print(count)


a = int(input())
l = []
cnt = 1
l.append(input())
for i in range(a - 1):
	b = input()
	if b == l[-1]:
		continue
	else:
		cnt += 1
	l.append(b)
print(cnt)


n = int(input())
c = 0
k = str(input())
if n == 1:
	print(1)
else:
	for i in range(n - 1):
		k1 = str(input())
		if k[-1] != k1[0]:
			c += 1
		k = k1
	print(n - c)


n = input
c = p = 0
for _ in ' ' * int(n()):
	s = n()
	c += s != p
	p = s
print(c)


num = int(input())
lis = []
for i in range(num):
	a = input()
	lis.append(a)
delim = ''
str1 = delim.join(lis)
str2 = str1.replace('00', '0 0')
str3 = str2.replace('11', '1 1')
print(str3.count(' ') + 1)


x = int(input())
number_of_groups = 1
m = []
for i in range(x):
	k = input()
	m.append(k)
for i in range(len(m) - 1):
	if m[i] != m[i + 1]:
		number_of_groups += 1
print(number_of_groups)


n = int(input())
magnets = []
res = 1
for i in range(n):
	magnets.append(input())
for i in range(n - 1):
	if magnets[i][1] == magnets[i + 1][0]:
		res += 1
print(str(res))


n = int(input())
l = []
s = ''
for i in range(n):
	a = input()
	if len(s) == 0:
		s += a
		continue
	if s[len(s) - 1] != a[0]:
		s += a
	else:
		s = a
		l.append(s)
l.append(s)
print(len(l))


n = input()
groups = 0
prev_signal = None
for _ in range(int(n)):
	current_signal = input()
	if prev_signal != current_signal:
		groups += 1
		prev_signal = current_signal
print(groups)


n = int(input())
last = None
grp = 1
for i in range(n):
	mag = input()
	if last is None:
		last = mag
	elif mag[0] == last[1]:
		grp += 1
	last = mag
print(grp)


no_magnets = int(input())
counter = 1
group_list = []
for i in range(no_magnets):
	group_list.append(input())
for i in range(1, len(group_list)):
	if group_list[i] == group_list[i - 1]:
		continue
	else:
		counter += 1
print(counter)


a = 0
cnt = 0
for i in range(int(input())):
	b = 1 if input()[0] == '0' else -1
	if a * b < 0:
		cnt += 1
	a = b
print(cnt + 1)


t = int(input())
l = []
for i in range(t):
	l.append(int(input()))
c = 1
j = 0
while j < t - 1:
	if l[j] != l[j + 1]:
		c = c + 1
	j = j + 1
print(c)


n = int(input())
k = list()
l = list()
for i in range(n):
	m = input()
	k.append(m)
for i in range(n - 1):
	a = int(k[i] == k[i + 1]) - 1
	l.append(a)
print(abs(sum(l)) + 1)


a = int(input())
c = []
cou = 0
for i in range(a):
	b = int(input())
	c.append(b)
for i in range(1, len(c)):
	if c[i] == c[i - 1]:
		continue
	else:
		cou += 1
print(cou + 1)


n = int(input())
x = []
cnt = 0
for i in range(0, n):
	a = int(input())
	x.append(a)
for i in range(1, n):
	if x[i - 1] != x[i]:
		cnt += 1
print(cnt + 1)


t = int(input())
lst = []
for i in range(0, t):
	k = input()
	lst.append(k)
i = 0
count = 0
while i < len(lst) - 1:
	if lst[i][1] == lst[i + 1][1]:
		i += 1
	else:
		i += 1
		count += 1
print(count + 1)


p = []
pas = 0
s = int(input())
for i in range(s):
	a = input()
	p.append(a)
for j in range(len(p) - 1):
	if p[j] == p[j + 1]:
		continue
	else:
		pas += 1
print(pas + 1)


n = int(input())
a = ''
ans = 1
for i in range(n):
	x = input()
	a += x
for j in range(1, len(a)):
	if a[j] == a[j - 1]:
		ans += 1
print(ans)


n = int(input())
count = 1
li = []
k = 0
for i in range(n):
	a = input()
	li.append(a)
for j in range(n):
	if j + 1 < n:
		if li[j][1] == li[j + 1][0]:
			count += 1
print(count)


n = int(input())
c = 0
lst = list()
for i in range(n):
	a = int(input())
	lst.append(a)
m = lst[0]
for i in lst:
	if i != m:
		c += 1
		m = i
print(c + 1)


num = int(input())
ls = []
for i in range(num):
	a = str(input())
	ls.append(a)
jml = 0
grup = 1
a = 0
n = 0
for x in range(len(ls) - 1):
	if ls[x] == ls[x + 1]:
		continue
	else:
		grup += 1
print(grup)


import math

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

def rotate(my_list, num):
	return my_list[num:] + my_list[:num]

def main():
	num = int(input())
	mylist = [0] * num
	answer = 1
	for i in range(num):
		magnet = int(input())
		mylist[i] = magnet
		if i > 0:
			if mylist[i - 1] != mylist[i]:
				answer += 1
	print(answer)
main()


import sys
if False:
	input = open('magnets.txt', 'r')
else:
	input = sys.stdin
n = int(input.readline().strip())
row = []
for i in range(n):
	m = input.readline().strip()
	row.append(m)
groups = 1
for magnet in range(n - 1):
	if row[magnet] != row[magnet + 1]:
		groups = groups + 1
print(groups)


from functools import reduce
from sys import stdin
file = stdin

def read_line():
	return file.readline().strip()

def read_int():
	return int(read_line())

def string_list_to_int_list(x):
	return [int(e) for e in x]
cases = read_int()
changes = 0
previous = '00'
for case in range(cases):
	now = read_line()
	if now != previous:
		changes += 1
	previous = now
print(changes)


x = int(input())
group = 1
if x == 1:
	magp = input()
	print(group)
else:
	magp = input()
	for i in range(x - 1):
		mag = input()
		if magp != mag:
			group += 1
			magp = mag
	print(group)


n = int(input())
magnets = list()
groups = 1
magnets.append(input())
for i in range(1, n):
	magnets.append(input())
	if magnets[i] != magnets[i - 1]:
		groups += 1
print(groups)


x = int(input())
g = 1
y = ''
z = ''
for i in range(x):
	if i == 0:
		y = input()
		continue
	else:
		z = input()
		if z != y:
			g += 1
	y = z
print(g)


num = int(input())
inpute = []
for i in range(num):
	i = input('')
	inpute.append(i)
count = 1
for i in range(num - 1):
	if inpute[i][1] == inpute[i + 1][0]:
		count += 1
print(count)


n = int(input())
x = 0
for i in range(n):
	m = input()
	if i == 0:
		k = m
	elif i > 0 and m != k:
		x += 1
		k = m
print(x + 1)


import sys
n = int(input())
counter = 0
last = 0
for i in range(n):
	j = int(input())
	if j != last:
		counter += 1
	last = j
print(counter)


a = b = 0
for _ in range(int(input())):
	n = int(input())
	if n == b:
		continue
	b = n
	a += 1
print(a)


def solve(magnets):
	if len(magnets) == 0:
		return 0
	count = 1
	lastPole = magnets[0][1]
	for i in range(1, len(magnets)):
		if magnets[i][0] == lastPole:
			count += 1
		lastPole = magnets[i][1]
	return count
n = int(input())
magnets = []
for i in range(n):
	m = input()
	magnets.append(m)
print(solve(magnets))


n1 = int(input())
arr = []
for i in range(n1):
	arr.append(input())
count = 0
for i in range(len(arr) - 1):
	if arr[i] == arr[i + 1]:
		continue
	else:
		count += 1
print(count + 1)


answer = 1
for i in range(int(input())):
	k = input()
	if i != 0:
		if last[1] == k[0]:
			answer += 1
	last = k
print(answer)


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
x = ''
cnt = 1
for i in range(t):
	p = input()
	if x == '':
		x = p
		continue
	if x[-1] == p[0]:
		cnt += 1
		x = p
		continue
	x = p
print(cnt)


n = int(input())
c = 0
a = []
prev = 0
for i in range(n):
	pres = int(input())
	if pres != prev:
		c += 1
	prev = pres
print(c)


n = int(input())
prev = '2'
groups = 1
for j in range(n):
	curr = input().strip()
	if curr[0] == prev:
		groups += 1
	prev = curr[1]
print(groups)


x = int(input())
c = 0
v = 2
for i in range(x):
	if v == 2:
		s = input()
		(a, b) = (s[0], s[1])
		v = b
	else:
		s = input()
		(a, b) = (s[0], s[1])
		if v == a:
			c = c + 1
		v = b
print(c + 1)


n = int(input())
count = 1
magnets = []
for _ in range(n):
	magnets.append(input())
for i in range(n - 1):
	if magnets[i] != magnets[i + 1]:
		count += 1
print(count)


N = int(input())
P = 1
L = []
C = input()
L.append(C)
for j in range(1, N):
	D = input()
	L.append(D)
	if L[j - 1] != L[j]:
		P += 1
print(P)


n = int(input())
polo = 'a'
gruppi = 0
for i in range(n):
	s = input()
	if s[1] != polo:
		gruppi += 1
	polo = s[1]
print(gruppi)


n = int(input())
A = []
for i in range(n):
	A.append(int(input()))
ans = 1
for i in range(1, len(A)):
	if A[i] != A[i - 1]:
		ans += 1
print(ans)


def solution():
	amount_of_magnits = int(input())
	magnit = input()
	check = magnit[1]
	counter = 1
	for i in range(amount_of_magnits - 1):
		magnit = input()
		if check != magnit[1]:
			counter += 1
			check = magnit[1]
	print(counter)
solution()


n = int(input())
mag = []
groups = 0
previous = '00'
for i in range(n):
	cur = input()
	if previous != cur:
		groups += 1
		previous = cur
	else:
		continue
print(groups)


n = int(input())
st = ''
for i in range(0, n):
	newMagnet = str(input())
	st = st + newMagnet
minusCount = st.count('00')
plusCount = st.count('11')
print(minusCount + plusCount + 1)


x = []
for n in range(int(input())):
	a = str(input())
	x.append(a)
temp = ''
count = 0
for i in x:
	if temp != i:
		count += 1
		temp = i
print(count)


a = int(input())
count = 0
past = 0
for i in ' ' * a:
	g = int(input())
	if g != past:
		count += 1
		past = g
print(count)


n = int(input())
previous = input()
count = 1
for _ in range(1, n):
	next = input()
	if next != previous:
		count += 1
	previous = next
print(count)


n = int(input())
x = []
for i in range(n):
	x.append(input())
qishi = x[0]
s = 1
for j in range(1, n):
	if x[j] != qishi:
		s += 1
		qishi = x[j]
print(s)


n = int(input())
x = '00'
c = 0
for i in range(n):
	a = input()
	if a != x:
		c += 1
	x = a
print(c)


import sys

def get():
	return int(sys.stdin.readline().strip())
(a, c) = (0, 0)
for _ in range(get()):
	n = get()
	if n != a:
		a = n
		c += 1
print(c)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
c = 1
for i in range(len(l) - 1):
	if l[i] == '10' and l[i + 1] == '01':
		c = c + 1
	elif l[i] == '01' and l[i + 1] == '10':
		c = c + 1
print(c)


_1 = '236a'
_2 = '339a'
_3 = '266a'
_4 = '96a'
_5 = '236a'
_6 = '281a'
_7 = '546a'
_8 = '116a'
_9 = '977a'
_10 = '266b'
_11 = '110a'
_12 = '41a'
_13 = '734a'
_14 = '133a'
_15 = '467a'
_16 = '158a'
_17 = '677a'
_18 = '580a'
_19 = '344a'
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
c = 1
t = l[0]
for i in range(1, n):
	if l[i] != t:
		c += 1
		t = l[i]
print(c)


n = int(input())
out = 1
list1 = []
for i in range(n):
	list1.append(input())
for i in range(n - 1):
	out += list1[i] != list1[i + 1]
print(out)


n = int(input())
group = 0
last = -1
for _ in range(n):
	m = input()
	if group == 0:
		group += 1
		last = m[1]
		continue
	if last == m[0]:
		group += 1
	last = m[1]
print(group)


x = int(input())
count = 1
new = []
for i in range(x):
	r = input()
	new.append(r)
for j in range(x - 1):
	if new[j] == new[j + 1]:
		continue
	else:
		count += 1
print(count)


n = int(input())
nn = [None] * (n + 1)
i = 0
while i in range(0, n):
	nn[i] = int(input())
	i += 1
s = 1
i = 0
for i in range(0, n):
	if nn[i] == nn[i + 1]:
		continue
	elif nn[i + 1] == None:
		break
	else:
		s += 1
print(s)


from sys import stdin, stdout
num = int(stdin.readline())
groups = 0
flag_i = False
flag_e = False
for i in range(num):
	inp = int(stdin.readline())
	if inp == 10:
		if flag_e:
			groups += 1
			flag_e = False
		flag_i = True
	else:
		if flag_i:
			groups += 1
			flag_i = False
		flag_e = True
stdout.write(str(groups + 1))


group = 0
last = 0
for i in range(int(input())):
	present = int(input())
	if last != present:
		group += 1
	last = present
print(group)


arr = []
count = 1
for i in range(int(input())):
	x = input()
	arr.append(x)
	if len(arr) == 0:
		continue
	if arr[i - 1] != x:
		count += 1
print(count)


n = int(input())
count = 1
lst = []
for i in range(0, n):
	lst.append(input())
	if i > 0:
		if lst[i - 1] == lst[i]:
			continue
		else:
			count += 1
print(count)


num = int(input())
magnet = 1
list = []
for i in range(0, num):
	list.append(str(input()))
for i in range(0, num):
	if i + 1 == num:
		break
	elif list[i] != list[i + 1]:
		magnet += 1
print(magnet)


ans = 1
bef = ''
for i in range(int(input())):
	a = input()
	if i > 0:
		if bef[-1] != a[0]:
			pass
		else:
			ans += 1
	bef = a
print(ans)


n = int(input())
a = []
groups = 1
for i in range(n):
	a.append(input())
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		groups += 1
print(groups)


n = int(input())
mg = ''
g = 1
for i in range(n):
	if i == 0:
		mg += input()
	else:
		temp = input()
		if mg[len(mg) - 1] == temp[0]:
			g += 1
		mg += temp
print(g)


a = int(input())
num = 0
last = ''
for k in range(a):
	b = input()
	if last == '':
		num += 1
	elif b != last:
		num += 1
	last = b
print(num)


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
l = 1
for i in range(len(arr) - 1):
	a = arr[i]
	b = arr[i + 1]
	if a[1] == b[0]:
		l = l + 1
print(l)


n = int(input())
s = set()
c = 0
prev = 0
for _ in range(n):
	k = int(input())
	if prev != k:
		prev = k
		c += 1
print(c)


n = int(input())
magnets = [int(input()) // 10 for i in range(n)]
islands = 1
q = magnets[0]
for i in magnets[1:]:
	if i != q:
		islands += 1
	q = i
print(islands)


n = int(input())
inpL = []
for z in range(n):
	s = str(input())
	inpL.append(s)
ans = 1
for i in range(0, n - 1):
	if inpL[i] != inpL[i + 1]:
		ans += 1
print(ans)


n = int(input())
m = list()
c = 1
for i in range(n):
	m.append(list(map(int, input().split())))
for i in range(n - 1):
	if m[i] != m[i + 1]:
		c = c + 1
print(c)


x = int(input())
c = 0
b = 0
for i in range(0, x):
	i = str(input())
	if i != b:
		c += 1
	b = i
print(c)


n = int(input())
L = []
k = 0
groups = []
for i in range(n):
	L.append(int(input()))
for i in range(len(L) - 1):
	if L[i + 1] == L[i]:
		k += 1
	else:
		groups.append(k)
		k = 1
print(len(groups) + 1)


(c, d, e) = (0, '0', 0)
for i in ' ' * int(input()):
	c = input()
	if c != d:
		e += 1
		d = c
print(e)


def solve(a):
	ret = 1
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			ret += 1
	return ret
print(solve([input()[0] for _ in range(int(input()))]))


n = int(input())
o = 0
pmagn = '00'
for i in range(n):
	magn = input()
	if magn != pmagn:
		o += 1
	pmagn = magn
print(o)


num = int(input())
if num == 1:
	print(1)
else:
	count = 1
	mag = []
	for n in range(0, num):
		mag.append(int(input()))
	for m in range(0, num - 1):
		if mag[m] != mag[m + 1]:
			count = count + 1
	print(count)


n = int(input())
my_list = []
for i in range(n):
	my_list.append(input()[-1])
counter = 1
for j in range(len(my_list) - 1):
	if my_list[j] != my_list[j + 1]:
		counter += 1
print(counter)


n = int(input())
c = 0
ch = ''
for i in range(n):
	s = input()
	c += s != ch
	ch = s
print(c)


n = int(input())
prev_Magnet = ''
groups = 0
for i in range(n):
	current_Magnet = input()
	if current_Magnet != prev_Magnet:
		groups += 1
	prev_Magnet = current_Magnet
print(groups)


n = int(input())
a = []
count = 1
a = [int(input()) for i in range(n)]
for x in range(n - 1):
	if a[x] == a[x + 1]:
		continue
	else:
		count += 1
print(count)


n = int(input()) - 1
t = s = 0
k = [input()]
for _ in [0] * n:
	nu = input()
	k.append(nu)
	if k[t] != k[t + 1]:
		s = s + 1
	t = t + 1
print(s + 1)


s = input
a = b = 0
for j in ' ' * int(s()):
	c = s()
	a += c != b
	b = c
print(a)


import sys
list1 = []
numlines = int(input())
numlines1 = numlines
total = 0
for line in sys.stdin:
	line = line[:-1]
	list1.append(line)
	numlines -= 1
	if numlines == 0:
		break
for i in range(numlines1):
	if i != numlines1 - 1:
		if list1[i] != list1[i + 1]:
			total += 1
total += 1
print(total)


a = int(input())
temp = ''
mag = ''
gr = 0
for i in range(a):
	mag = input()
	if temp != mag:
		temp = mag
		gr += 1
print(gr)


n = int(input())
out = ''
i = 0
c = 1
while i < n:
	out += input()
	i += 1
for j in range(len(out) - 1):
	if out[j] == out[j + 1]:
		c += 1
print(c)


n = int(input().strip(' '))
groups = 0
current = ''
for i in range(n):
	mgt = input().strip(' ')
	if groups == 0 and current == '':
		groups += 1
		current = mgt
	elif current[1] == mgt[0]:
		groups += 1
		current = mgt
print(groups)


n = int(input())
l = []
str1 = ''
for i in range(n):
	l.append(input())
for i in range(n):
	if i != n - 1:
		if l[i] == l[i + 1]:
			str1 += l[i]
		elif l[i] != l[i + 1]:
			str1 += l[i] + ' '
	elif i == n - 1:
		str1 += l[i]
a = str1.split()
print(len(a))


n = int(input())
mas = []
k = 1
for i in range(0, n, 1):
	mas.append(str(input()))
for i in range(0, n - 1, 1):
	if mas[i][1] == mas[i + 1][0]:
		k = k + 1
print(k)


k = 1
a = '1'
for x in range(int(input())):
	s = input()
	b = s[0]
	if x == 0:
		a = s[1]
		continue
	if a == b:
		k += 1
	a = s[1]
print(k)


n = int(input())
iList = []
for i in range(n):
	iList.append(input())
first = iList[0]
count = 1
for j in range(1, n):
	if first == iList[j]:
		first = iList[j]
	else:
		first = iList[j]
		count = count + 1
print(count)


n = int(input())
itr = 1
islands = 1
prevDomino = input()
while itr < n:
	nextDomino = input()
	if prevDomino[1] == nextDomino[0]:
		islands = islands + 1
	prevDomino = nextDomino
	itr = itr + 1
print(islands)


n = int(input())
count = 1
num2 = int(input())
num = []
num.append(num2)
for j in range(1, n):
	num1 = int(input())
	num.append(num1)
	if num[j] == num[j - 1]:
		count = count
	else:
		count += 1
print(count)


t = int(input())
ans = 0
prev = ''
for _ in range(t):
	magnets = input()
	if prev != magnets:
		prev = magnets
		ans += 1
print(ans)


a = []
x = int(input())
for i in range(x):
	n = int(input())
	a.append(n)
d = 1
for i in range(x - 1):
	if a[i] == 10 and a[i + 1] == 1:
		d += 1
	elif a[i] == 1 and a[i + 1] == 10:
		d += 1
print(d)


n = int(input())
t = 0
A = []
for i in range(n):
	A.append(input())
	if i >= 1:
		if A[1] == A[0]:
			pass
		else:
			t = t + 1
		del A[0]
print(t + 1)


n = int(input())
d = 1
for i in range(0, n):
	s = input()
	if i != 0 and s != c:
		d += 1
	c = s
print(d)


qtd = int(input())
seq = list()
for i in range(qtd):
	seq.append(input())
cont = 0
lista = list(''.join(seq))
for i in range(len(lista) - 1):
	if lista[i] == lista[i + 1]:
		cont += 1
print(cont + 1)


n = int(input())
group = 0
x = []
if n == 1:
	print(1)
else:
	for i in range(n):
		s = input()
		if i == 0:
			group = group + 1
			x.append(s[1])
		else:
			if s[0] == x[i - 1]:
				group = group + 1
			x.append(s[1])
	print(group)


a = int(input())
x = []
sum = 0
for i in range(a):
	b = input()
	x.append(b)
x = ''.join(x)
c = int(len(x))
for hu in range(c):
	if c > hu + 1:
		if x[hu] == x[hu + 1]:
			sum += 1
print(sum + 1)


n = int(input())
lis = []
for i in range(n):
	x = input()
	lis.append(x)
c = 0
for i in range(1, len(lis)):
	if lis[i] == '01' and lis[i - 1] == '10':
		c += 1
	elif lis[i] == '10' and lis[i - 1] == '01':
		c += 1
	else:
		continue
print(c + 1)


class magnets:

	def main():
		n = int(input())
		c = 1
		a = input()
		for i in range(n - 1):
			b = a
			a = input()
			if a != b:
				c += 1
		print(c)
	main()


n = int(input()) - 1
g = 1
x = input()
while n:
	y = input()
	if x != y:
		g += 1
	x = y
	n -= 1
print(g)


t = int(input())
x = []
for i in range(t):
	a = int(input())
	x.append(a)
sum = 1
for j in range(0, t - 1):
	if x[j] != x[j + 1]:
		sum = sum + 1
print(sum)


n = int(input())
g = 0
l = ''
for i in range(0, n):
	m = input()
	if i == 0:
		g = 1
	elif m[0] == l[1]:
		g = g + 1
	l = m
print(g)


n = int(input())
g = 1
for i in range(n):
	if i == 0:
		s = input()
		last = s[-1]
	else:
		s = input()
		if last != s[-1]:
			g = g + 1
		last = s[-1]
print(g)


import sys
n = int(sys.stdin.readline().split()[0])
magnets = []
for line in sys.stdin:
	for word in line.split():
		magnets.append(word)
islands = 1
i = 0
while i < n - 1:
	if magnets[i] != magnets[i + 1]:
		islands += 1
	i += 1
print(islands)


qtd = int(input())
mem = nw = mark = 0
while qtd > 0:
	nw = int(input())
	if mem != nw:
		mark += 1
		mem = nw
	qtd -= 1
print(mark)


n = int(input())
lst = []
for i in range(n):
	l = input()
	lst.append(l)
lst = ''.join(lst)
print(lst.count('00') + lst.count('11') + 1)


n = int(input())
prev = input()
total = 1
for _ in range(n - 1):
	tmp = input()
	if tmp != prev:
		total += 1
	prev = tmp
print(total)


def push(arr, new):
	arr[0] = arr[1]
	arr[1] = new
n = int(input())
if n == 1:
	print(1)
	exit()
a = [input(), input()]
if a[0] == a[1]:
	c = 1
else:
	c = 2
for i in range(n - 2):
	push(a, input())
	if a[0] != a[1]:
		c += 1
print(c)


a = int(input())
inputs = []
n = 0
while n < a:
	y = input()
	n += 1
	inputs.append(y)
i = 0
count = 1
while i < a - 1:
	b = list(inputs[i])
	c = list(inputs[i + 1])
	if b[1] == c[0]:
		count += 1
	i += 1
print(count)


n = int(input())
count = 0
prev = ''
for i in range(n):
	temp = input()[1]
	if prev == '':
		count += 1
	elif prev != temp:
		count += 1
	prev = temp
print(count)


n = int(input())
m = 1
s = input()
while n - 1:
	k = input()
	if s != k:
		m += 1
	s = k
	n += -1
print(m)


n = int(input())
p01 = '01'
p10 = '10'
res = 0
state = ''
for i in range(n):
	x = input()
	if x != state:
		res += 1
		state = x
print(res)


__author__ = 'Catherine'
n = int(input())
a = [-1]
ans = 1
j = 0
for i in range(n):
	m = input()
	a.append(int(m[0]))
	if a[j + 1] == a[j]:
		ans += 1
	a.append(int(m[1]))
	j += 2
print(ans)


n = int(input())
a = [input() for i in range(n)]
print(sum((1 for i in range(n - 1) if a[i] != a[i + 1])) + 1)


n = int(input())
arr = ''
count = 0
for i in range(n):
	arr += input()
for j in range(len(arr) - 1):
	if arr[j] == arr[j + 1]:
		count += 1
print(count + 1)


n = int(input())
prev = ''
st = 0
for i in range(n):
	now = input()
	if now != prev:
		st += 1
	prev = now
print(st)


n = [int(i) for i in input().split()][0]
pred = input()
ctr = 1
for i in range(1, n):
	cur = input().split()[0]
	if pred != cur:
		ctr += 1
		pred = cur
print(ctr)


from sys import stdin, stdout
n = int(input())
count = 1
first = stdin.readline()
for k in range(1, n):
	a = stdin.readline()
	if a != first:
		count += 1
	first = a
print(count)


num = int(input())
cnt = 0
for i in range(num):
	word = input()
	if cnt == 0:
		now = word
		cnt += 1
	elif now[1] == word[0]:
		now = word
		cnt += 1
print(cnt)


n = int(input())
r = [input() for i in range(n)]
pares = 0
for i in range(0, len(r)):
	if i != len(r) - 1:
		if r[i] != r[i + 1]:
			pares += 1
print(pares + 1)


a = int(input())
b = []
b.append(int(input()))
sum = 1
for i in range(1, a):
	b.append(int(input()))
	if b[i] % 10 != b[i - 1] % 10:
		sum += 1
print(sum)


n = int(input())
s = ''
ct = 1
for i in range(n):
	if input() == '10':
		s += 'x'
	else:
		s += 'y'
for i in range(n - 1):
	if s[i] != s[i + 1]:
		ct += 1
print(ct)


n = int(input())
previous = 100
answer = 0
for i in range(n):
	current = int(input())
	if current != previous:
		answer += 1
	previous = current
print(answer)


n = int(input())
ans = 1
arr = []
while n != 0:
	a = int(input())
	arr.append(a)
	n -= 1
for i in range(1, len(arr)):
	if arr[i - 1] != arr[i]:
		ans += 1
print(ans)


n = int(input())
if n == 1:
	print(1)
	exit(0)
a = input()
t = 1
for el in range(n - 1):
	b = input()
	if a[-1] == b[0]:
		t += 1
	a = b
print(t)


n = int(input())
a = []
ostrov = 0
for i in range(n):
	k = input()
	a.append(k)
	if len(a) == 1:
		ostrov += 1
	elif a[0] == a[1]:
		del a[0]
	else:
		ostrov += 1
		del a[0]
print(ostrov)


magnets = int(input())
groups = 1
for magnet in range(magnets):
	if magnet == 0:
		past = input()
		continue
	current = input()
	if current != past:
		groups += 1
		past = current
print(groups)


def main():
	n = int(input())
	c = 1
	x = int(input())
	for i in range(1, n):
		y = int(input())
		if x != y:
			c += 1
			x = y
	print(c)
main()


n = int(input())
a = []
counter = 1
for x in range(n):
	a.append(int(input()))
for i in range(n):
	if i > 0:
		if a[i - 1] != a[i]:
			counter += 1
if n == 1 or n == 2:
	counter = 1
if n == 2 and a[0] != a[1]:
	counter = 2
print(counter)


import sys, io
f = io.BytesIO(sys.stdin.buffer.read())
(c, t) = (0, bytes())
for s in f.readlines()[1:]:
	if s != t:
		c += 1
	t = s
print(c)


n = int(input())
a = []
c = 1
for i in range(n):
	a.append(input())
b = ''.join(a)
for i in range(1, 2 * n - 1, 2):
	if b[i:i + 2] == '00' or b[i:i + 2] == '11':
		c += 1
print(c)


n = int(input())
row = ''
for i in range(n):
	row += input()
groups = 1
for i in range(0, len(row)):
	try:
		if row[i] == row[i + 1]:
			groups += 1
	except:
		pass
print(groups)


g = 0
mag = ''
for _ in range(int(input())):
	mag += input()
print(mag.count('00') + mag.count('11') + 1)


magnets_count = int(input())
prev_mag = input()
groups = 1
for _ in range(magnets_count - 1):
	mag = input()
	if prev_mag != mag:
		groups += 1
	prev_mag = mag
print(groups)


n = int(input())
prev_inp = int(input())
group = 1
for _ in range(n - 1):
	curr_inp = int(input())
	if prev_inp != curr_inp:
		group += 1
		prev_inp = curr_inp
print(group)


n = int(input())
list1 = []
c = 1
for i in range(n):
	k = input()
	list1.append(k)
for i in range(len(list1) - 1):
	if list1[i] != list1[i + 1]:
		c += 1
print(c)


(c, prev) = (0, '01')
for i in range(0, int(input())):
	s = input()
	if i == 0:
		prev = s
	if i > 0:
		if prev[1] == s[0]:
			c += 1
		prev = s
c += 1
print(c)


def magnets(arr):
	count = 1
	for i in range(len(arr) - 1):
		if arr[i] != arr[i + 1]:
			count += 1
	return count
n = int(input().strip())
arr = []
for i in range(n):
	arr.append(input().strip())
print(magnets(arr))


string = 'prof yhf is great!'
for i in range(int(input())):
	string += input()
print(string.count('00') + string.count('11') + 1)


n = int(input())
p = int(input())
k = 1
for i in range(1, n):
	d = int(input())
	if p != d:
		k = k + 1
	p = d
print(k)


n = int(input())
a = [input() for _ in range(n)]
r = 1
for i in range(1, n):
	if a[i] != a[i - 1]:
		r += 1
print(r)


import sys
n = int(input())
magnets = []
for i in range(1, n + 1):
	magnets.append(input())
value = magnets[0]
counter = 1
for magnet in magnets:
	if magnet != value:
		counter += 1
	value = magnet
print(counter)


n = int(input().strip())
prev = None
groups = 0
for i in range(n):
	curr = input().strip()
	if not prev or curr != prev:
		prev = curr
		groups += 1
print(groups)


import sys
lines = sys.stdin.readlines()
N = int(lines[0].strip())
count = 1
for i in range(1, N):
	if lines[i].strip() != lines[i + 1].strip():
		count += 1
print(count)


n = int(input())
n_groups = 1
last_mag = input()
for i in range(n - 1):
	curr_mag = input()
	if curr_mag != last_mag:
		n_groups += 1
	last_mag = curr_mag
print(str(n_groups))


l2 = []
group = 1
nextgrp = False
n = int(input())
for i in range(n):
	l2.append(input())
for i in range(n - 1):
	if l2[i] != l2[i + 1]:
		group += 1
print(group)


a = int(input())
if a > 0:
	count = 1
	temp = input()
for i in range(a - 1):
	d = input()
	if d != temp:
		count += 1
	temp = d
print(count)


from sys import stdin, stdout
inints = lambda : [int(x) for x in stdin.readline().split()]
fastwrite = lambda s: stdout.write(str(s) + '\n')
irange = lambda x, y: range(x, y + 1)
(n,) = inints()
prev = ''
r = 0
for x in range(n):
	s = stdin.readline()
	if prev != s:
		r += 1
	prev = s
fastwrite(r)


n = int(input())
l = []
for tcs in range(n):
	l.append(input())
cnt = 1
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		cnt += 1
print(cnt)


n = int(input())
k1 = 0
s = 0
k = 0
for i in range(n):
	k1 = k
	k = int(input())
	if k1 != k:
		s += 1
if n == 1:
	print(1)
else:
	print(s)


n = int(input())
a = str()
counter = 1
for i in range(n):
	a += input()
for i in range(1, len(a)):
	if a[i] == a[i - 1]:
		counter += 1
print(counter)


a = int(input())
count = 1
x = []
for i in range(0, a):
	b = int(input())
	x.append(b)
c = x[0]
for j in range(1, len(x)):
	if c == x[j]:
		c == x[j]
	else:
		c = x[j]
		count += 1
print(count)


t = int(input())
lista = []
for x in range(t):
	num = int(input())
	lista.append(num)
cont = 1
num = lista[0]
for x in range(t):
	if lista[x] != num:
		cont += 1
		num = lista[x]
print(cont)


number = int(input())
ptr = []
counter = 1
temp = []
for i in range(number):
	ptr.append(input())
for i in range(len(ptr)):
	if i + 1 == len(ptr):
		temp.append(counter)
		break
	if ptr[i] == ptr[i + 1]:
		counter += 1
	else:
		temp.append(counter)
		counter = 1
print(len(temp))


n = int(input())
count = 1
g = []
for x in range(0, n):
	k = str(input())
	g.append(k)
for i in range(0, n - 1):
	if g[i] != g[i + 1]:
		count += 1
print(count)


n = int(input())
L = []
c = 1
for _ in range(n):
	i = input()
	if i == '10':
		if len(L) == 0:
			L.append(1)
		elif L[len(L) - 1] == 1:
			L.append(1)
		else:
			c = c + 1
			L.append(1)
	elif i == '01':
		if len(L) == 0:
			L.append(0)
		elif L[len(L) - 1] == 0:
			L.append(0)
		else:
			c = c + 1
			L.append(0)
print(c)


import os
import sys
from io import BytesIO, IOBase

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def main():
	n = ii()
	arr = list()
	for i in range(n):
		arr.append(ii())
	res = 1
	for i in range(1, n):
		if arr[i - 1] != arr[i]:
			res += 1
	print(res)
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')
main()


import sys
n = int(input())
s = ''
for i in range(n):
	s += input()
a = 1
for i in range(2 * n - 1):
	if s[i] == s[i + 1]:
		a += 1
print(a)


n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a)
c = 1
num = 1
for i in range(len(l) - 1):
	if l[i][-1] != l[i + 1][0]:
		c = c + 1
	if l[i][-1] == l[i + 1][0]:
		c = 1
		num = num + 1
print(num)


a = input()
k = [input().split() for i in range(int(a))]
count = 1
count_act = 1
for i in range(int(a) - 1):
	if k[i] != k[i + 1]:
		count += 1
print(count)


def main():
	n = int(input())
	ans = 1
	a = input()
	for _ in range(1, n):
		b = input()
		if b == a:
			continue
		else:
			ans += 1
			a = b
	print(ans)
main()


n = int(input())
l = []
c = 1
for _ in range(n):
	l.append(input())
for i in range(n - 1):
	if l[i] == l[i + 1]:
		pass
	else:
		c += 1
print(c)


l = list()
c = 1
for _ in range(int(input())):
	s = input()
	l.append(s)
for i in range(len(l) - 1):
	if l[i][1] == l[i + 1][0]:
		c += 1
print(c)


n = int(input())
cnt = 0
lis = []
for i in range(n):
	x = int(input())
	lis.append(x)
for i in range(n - 1):
	if lis[i] - lis[i + 1] == 0:
		pass
	else:
		cnt += 1
print(cnt + 1)


N = int(input())
A = []
for k in range(N):
	L = int(input())
	A.append(L)
Aux = A[0]
Contador = 1
for k in range(len(A)):
	if Aux != A[k]:
		Contador += 1
		Aux = A[k]
print(Contador)


n = int(input())
my_list = []
count = 1
for i in range(0, n):
	i = int(input())
	my_list.append(i)
for v in range(0, n - 1):
	c = int(v)
	if my_list[c] != my_list[c + 1]:
		count += 1
print(count)


n = int(input())
pre = input()
sum = 1
i = 1
while i < n:
	cur = input()
	if cur != pre:
		sum += 1
	pre = cur
	i += 1
print(sum)


x = int(input())
l = []
for y in range(x):
	s = input()
	if s == '01':
		l.append('+')
	else:
		l.append('-')
i = 0
output = []
for (a, b) in zip([float('nan')] + l, l):
	if a != b:
		output.append([])
	output[-1].append(b)
print(len(output))


from sys import stdin
n = int(stdin.readline())
t = stdin.readline()
count = 1
for i in range(1, n):
	f = stdin.readline()
	if f != t:
		count += 1
	t = f
print(count)


x = int(input())
t = 1
y = []
for i in range(x):
	y.append(input())
for i in range(x - 1):
	if y[i] != y[i + 1]:
		t = t + 1
print(t)


n = int(input())
prev = input()
result = 1
for a in range(n - 1):
	now = input()
	if now != prev:
		result += 1
	prev = now
print(result)


x = int(input())
l = []
k = 0
for i in range(x):
	y = input()
	l.append(y)
for j in range(x - 1):
	if l[j] == l[j + 1]:
		k += 0
	else:
		k += 1
if k == 0:
	k = len(set(l))
else:
	k += 1
print(k)


n = int(input())
array = [input() for x in range(n)]
count = 1
for i in range(1, len(array)):
	if array[i] != array[i - 1]:
		count += 1
print(count)


n = int(input())
lastone = ''
count = 1
for i in range(n):
	new_one = input()
	if lastone[-1:] == new_one[0:1]:
		count += 1
	lastone = new_one
print(count)


n = int(input())
last = ''
result = 0
for i in range(n):
	v = input()
	if v != last:
		result += 1
		last = v
print(result)


n = int(input())
s = ''
l = [input() for _ in range(n)]
l = ''.join(l)
for i in range(len(l)):
	try:
		if l[i] != l[i + 1]:
			s += l[i]
		else:
			s += l[i]
			s += ' '
	except:
		s += l[i]
print(len(s.split()))


t = int(input())
s = input()
c = 0
for i in range(t - 1):
	last = s[-1]
	s = input()
	first = s[0]
	if last == first:
		c += 1
print(1 + c)


n = int(input())
flag = 0
c = 0
for _ in range(n):
	a = int(input())
	if flag == 0:
		c += 1
		flag = a
	elif flag == a:
		flag = a
	else:
		c += 1
		flag = a
print(c)


n = int(input())
s = int(input())
c = 1
for i in range(n - 1):
	snew = int(input())
	if snew != s:
		c += 1
	s = snew
print(c)


n = int(input())
s = ''
number_magnets = 1
for i in range(n):
	x = input()
	s += x
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		number_magnets += 1
print(number_magnets)


n = int(input())
p = input()
coun = 1
for i in range(n - 1):
	a = input()
	if p != a:
		coun += 1
		p = a
print(coun)


f = int(input())
q = ''
w = 0
for i in range(1, f + 1):
	x = str(input())
	if q == x[0]:
		w = w + 1
	q = x[1]
print(w + 1)


aux = '0'
cont = 0
n = int(input())
for _ in range(n):
	i = input()
	if i != aux:
		cont += 1
		aux = i
print(cont)


n = int(input())
count = 0
p = 0
for i in range(n):
	s = int(input())
	if p != s:
		count += 1
		p = s
	else:
		p = s
print(count)


n = int(input())
d = 1
x = int(input())
for i in range(n - 1):
	x1 = int(input())
	if x1 != x:
		d += 1
	x = x1
print(d)


n = int(input())
al = []
ans = 0
for i in range(n):
	t = input()
	al.append(t)
for i in range(n - 1):
	if al[i] != al[i + 1]:
		ans += 1
print(ans + 1)


Casos = input()
N = int(Casos)
I = input()
Aux = str(I)
Contador = 1
for k in range(1, N):
	A = input()
	Iman = str(A)
	if Iman != Aux:
		Contador += 1
		Aux = Iman
print(Contador)


n = int(input())
l = []
t = 0
z = 0
for i in range(n):
	a = int(input())
	l.append(a)
for i in l[:-1]:
	if i != l[t + 1]:
		z += 1
	t += 1
print(z + 1)


n = int(input())
a = 0
p = ''
for i in range(n):
	f = str(input())
	if f != p:
		a += 1
	p = f
print(a)


n = int(input())
counter = 0
magnet_list = []
last_magnet = '-1'
islands = 0
while counter < n:
	magnet = input()
	magnet_list.append(magnet)
	counter += 1
for mgn in magnet_list:
	if last_magnet == '-1':
		last_magnet = mgn
		islands += 1
		continue
	if mgn != last_magnet:
		last_magnet = mgn
		islands += 1
print(islands)


def check_group(magnet_group):
	(count, counter) = (0, 1)
	try:
		for magnet in magnet_group:
			if magnet != magnet_group[count + 1]:
				counter += 1
			count += 1
	except IndexError:
		print(counter)
n = int(input())
magnet_group = []
for _ in range(n):
	magnet = input()
	magnet_group.append(magnet)
check_group(magnet_group)


n = int(input())
a = []
for x in range(n):
	a.append(int(input()))
l = 0
cnt = 0
while l < len(a):
	if l == len(a) - 1:
		cnt += 1
		break
	for x in range(l, len(a) - 1):
		if a[l] != a[l + 1]:
			cnt += 1
			l += 1
			break
		l += 1
print(cnt)


x = int(input())
alist = []
for i in range(x):
	y = int(input())
	alist.append(y)
z = 1
for k in range(len(alist) - 1):
	if alist[k] != alist[k + 1]:
		z = z + 1
print(z)


t = int(input())
f = []
c = 1
for i in range(t):
	n = int(input())
	f.append(n)
for i in range(len(f) - 1):
	if f[i] == f[i + 1]:
		continue
	else:
		c = c + 1
print(c)


n = int(input())
l = []
for i in range(n):
	k = str(input())
	l.append(k)
num = 1
for j in range(0, len(l) - 1):
	if l[j] != l[j + 1]:
		num += 1
print(num)


N = int(input())
list = []
count = 0
for i in range(N):
	str = input()
	list.append(str)
	if i != 0:
		if list[i] != list[i - 1]:
			count += 1
print(count + 1)


import itertools as it
n = input()
count = 0
magnets = [input() for i in range(int(n))]
for (key, group) in it.groupby(magnets):
	count = count + 1
print(count)


n = int(input(''))
groupMagnet = 0
currentMagnet = ''
for i in range(n):
	magnet = input('')
	if currentMagnet != magnet:
		groupMagnet += 1
		currentMagnet = magnet
print(groupMagnet)


n = int(input())
present = ''
previous = ''
count = 0
for i in range(n):
	present = input()
	if present != previous:
		count += 1
	previous = present
print(count)


ammount = int(input())
groups = 0
x = []
for i in range(ammount):
	x.append(input())
group = 1
for i in range(ammount - 1):
	if int(x[i]) != int(x[i + 1]):
		group += 1
print(group)


n = int(input())
L = []
num = 1
for i in range(n):
	magnet = input()
	L.append(magnet)
if len(L) == 1:
	print('1')
else:
	for i in range(len(L) - 1):
		if int(L[i][1]) == int(L[i + 1][0]):
			num = num + 1
	print(num)


n = int(input())
rows = []
count = 0
for i in range(n):
	num = int(input())
	rows.append(num)
for i in range(n - 1):
	if rows[i] != rows[i + 1]:
		count += 1
print(count + 1)


n = int(input())
ans = []
while n:
	n -= 1
	a = int(input())
	ans.append(a)
counter = 1
for i in range(len(ans) - 1):
	if ans[i] != ans[i + 1]:
		counter += 1
print(counter)


n = int(input())
i = 1
c = 1
a = input()
while i < n:
	b = input()
	i += 1
	if a == b:
		continue
	else:
		c += 1
		a = b
print(c)


N = int(input())
ans = 0
last = ''
while N > 0:
	inp = input()
	if inp != last:
		ans += 1
	last = inp
	N -= 1
print(ans)


n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(x)
c = 1
for i in range(n - 1):
	s = a[i]
	l = a[i + 1]
	if s[-1] == l[0]:
		c += 1
print(c)


n = int(input())
ret = prev = 0
for i in range(n):
	cur = input()
	ret += cur != prev
	prev = cur
print(ret)


magnets = input('')
previous = ''
ans = 0
for i in range(int(magnets)):
	current = input('')
	if current != previous:
		ans += 1
	previous = current
print(ans)


n = int(input())
prev_magnet = int(input())
x = 1
for i in range(n - 1):
	current_magnet = int(input())
	if current_magnet != prev_magnet:
		x += 1
	prev_magnet = current_magnet
print(x)


n = int(input())
s = ''
for i in range(0, n):
	s += input()
ans = 1
for i in range(1, int(len(s) / 2)):
	if s[2 * i - 1] == s[2 * i]:
		ans += 1
print(ans)


magnets = int(input())
oldMag = int(input())
count = 1
for x in range(magnets - 1):
	mag = int(input())
	if mag != oldMag:
		count += 1
	oldMag = mag
print(count)


t = int(input())
x = str(input())
c = 0
for i in range(t - 1):
	a = str(input())
	if a != x:
		c += 1
		x = a
print(c + 1)


magnets = int(input())
c = 1
prev = int(input())
for i in range(1, magnets):
	s = int(input())
	if prev != s:
		prev = s
		c += 1
print(c)


n = int(input())
last = input()
islands = 1
for i in range(2, n + 1):
	magnit = input()
	if magnit != last:
		islands += 1
	last = magnit
print(islands)


n = int(input())
x = 0
old = int(input())
for i in range(1, n):
	new = int(input())
	if old != new:
		x += 1
		old = new
print(x + 1)


__author__ = 'JohnHook'
n = int(input())
arr = list()
k = 0
for i in range(n):
	if len(arr) == 0:
		arr.append(input())
		continue
	t = input()
	if arr[len(arr) - 1] == t:
		arr.append(t)
		continue
	arr.clear()
	arr.append(t)
	k += 1
print(k + 1)


a = int(input())
c = []
c1 = []
count = 0
for j in range(a):
	c1.append(int(input()))
c.append(c1[0])
for i in range(1, a):
	if c1[i] != c[-1]:
		c.append(c1[i])
print(len(c))


num = int(input())
a = [0] * num
for i in range(num):
	a[i] = int(input())
count = 1
for j in range(i):
	if a[j] != a[j + 1]:
		count += 1
print(count)


n = int(input())
groups = 1
line = [0] * n
for i in range(n):
	a = input()
	if a == '10':
		line[i] = 1
	if i == 0:
		continue
	if line[i - 1] != line[i]:
		groups += 1
print(groups)


n = int(input())
t = input()
c = 1
for i in range(n - 1):
	t1 = input()
	if t1 == t:
		continue
	else:
		c += 1
		t = t1
print(c)


n = int(input())
group = 0
prev_magnet = ''
for i in range(n):
	curr_magnet = input()
	if prev_magnet != curr_magnet:
		group += 1
	prev_magnet = curr_magnet
print(group)


z = 0
b = 99
n = int(input())
x = 0
while x < n:
	x = x + 1
	a = input()
	if a != b:
		z = z + 1
	b = a
print(z)


a = int(input())
d = 10
count = 1
for i in range(a):
	b = input()
	if d != 10:
		if d == b[0]:
			count += 1
	d = b[-1]
print(count)


n = int(input())
a = []
counter = 1
for i in range(n):
	x = int(input())
	a.append(x)
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		counter += 1
	else:
		continue
print(counter)


def main():
	n = int(input())
	groups = 1
	magnets = ''
	for i in range(0, n):
		magnets = magnets + input()
	magnets = list(magnets)
	for i in range(1, 2 * n):
		if magnets[i] == magnets[i - 1]:
			groups = groups + 1
	print(groups)
main()


n = int(input())
a = list()
for i in range(n):
	a.append(input())
i = 0
j = 0
while i < len(a) - 1:
	if a[i] != a[i + 1]:
		j += 1
	i += 1
print(j + 1)


t = int(input())
g = 1
previous = input()
t = t - 1
while t > 0:
	current = input()
	if current[0] != previous[0]:
		g += 1
		previous = current
	t = t - 1
print(g)


num = int(input())
ranklist = []
group = 1
for i in range(0, num):
	g = int(input())
	ranklist.append(g)
for i in range(1, len(ranklist)):
	if ranklist[i] == ranklist[i - 1]:
		group = group
	elif ranklist[i] != ranklist[i - 1]:
		group += 1
print(group)


magnet_number = int(input())
magnets = []
for magnet in range(magnet_number):
	magnets.append(input())
magnet_string = ''.join(magnets)
number11 = magnet_string.count('11')
number00 = magnet_string.count('00')
print(number11 + number00 + 1)


n = int(input())
x = ''
y = 0
for i in range(n):
	s = str(input())
	x += s
y = x.count('00')
y += x.count('11')
print(y + 1)


counter = int(input())
temp = ''
ans = 0
while counter:
	x = input()
	if len(temp) == 0:
		temp += x
	else:
		if temp[-1] == x[0]:
			ans += 1
		temp += x
	counter -= 1
print(ans + 1)


times = int(input())
current_mag = input()
total_groups = 1
for i in range(times - 1):
	inp = input()
	if inp != current_mag:
		total_groups += 1
		current_mag = inp
print(total_groups)


n = int(input())
start = input()[1]
swaps = 1
for i in range(n - 1):
	if input()[1] != start:
		if start == '0':
			start = '1'
		else:
			start = '0'
		swaps += 1
print(swaps)


N = int(input())
List = []
count = 0
for _ in range(N):
	List.append(int(input()))
cmp = 0
for i in range(0, N):
	if List[i] == cmp:
		pass
	else:
		cmp = List[i]
		count += 1
print(count)


from sys import stdin, exit
n = int(stdin.readline())
groups = 1
magnets = [line.rstrip() for line in stdin.readlines()]
for i in range(1, len(magnets)):
	if magnets[i - 1] != magnets[i]:
		groups += 1
print(groups)


t = int(input())
n = 1
prev = int(input())
for i in range(1, t):
	temp = int(input())
	if temp != prev:
		n += 1
	prev = temp
print(n)


countGroup = 0
x = int(input())
li = []
for i in range(x):
	li.insert(i, int(input()))
for ii in range(len(li) - 1):
	if li[ii] == li[ii + 1]:
		continue
	else:
		countGroup = countGroup + 1
if len(li) != 0:
	countGroup = countGroup + 1
print(countGroup)


n = int(input())
lst1 = []
c = 1
for i in range(n):
	lst1.append(input())
for j in range(1, n):
	if lst1[j] == lst1[j - 1]:
		continue
	else:
		c += 1
print(c)


n = int(input())
s = []
count = 1
for i in range(n):
	s.append(input())
for i in range(n - 1):
	if s[i] == '10' and s[i + 1] == '01':
		count += 1
	if s[i] == '01' and s[i + 1] == '10':
		count += 1
print(count)


x = '10'
y = '01'
fichas = int(input())
grupos = 1
centinela = input()
for i in range(0, fichas - 1):
	centinela2 = input()
	if centinela2 != centinela:
		grupos += 1
		centinela = centinela2
print(grupos)


entrada = int(input())
previous = ''
if entrada > 0:
	grupos = 1
else:
	grupo = 0
for i in range(entrada):
	mag = input()
	if previous != '':
		if previous[0] != mag[0]:
			grupos += 1
	previous = mag
print(grupos)


n = int(input())
prev = ''
cnt = 0
for i in range(n):
	if i == 0:
		mag = input()
		prev = mag
	else:
		mag = input()
		if mag != prev:
			cnt += 1
		prev = mag
cnt += 1
print(cnt)


a = int(input())
l = []
c = 0
for i in range(a):
	b = input()
	if b not in l:
		l = []
		l.append(b)
		c += 1
print(c)


lst = []
ans = 1
for i in range(int(input())):
	lst.append(int(input()))
for i in range(len(lst) - 1):
	if lst[i] != lst[i + 1]:
		ans += 1
print(ans)


n = int(input())
l = list()
for i in range(n):
	a = int(input())
	if a == 10:
		l.append(1)
		l.append(0)
	else:
		l.append(0)
		l.append(1)
cnt = 0
for i in range(len(l)):
	if i != len(l) - 1:
		if l[i] == l[i + 1]:
			cnt += 1
print(cnt + 1)


n = int(input())
prev = input()
ans = 0
for i in range(n - 1):
	cur = input()
	if cur[0] == prev[1]:
		ans += 1
	prev = cur
print(ans + 1)


n = int(input())
c = 0
d = 0
t = 0
e = []
for j in range(n):
	a = int(input())
	e.append(a)
for i in range(n - 1):
	if e[i] != e[i + 1]:
		c = c + 1
print(c + 1)


n = int(input())
a = []
for i in range(n):
	a.append(input())
res = 0
for i in range(n - 1):
	if a[i] == '10' and a[i + 1] == '01':
		res += 1
	if a[i] == '01' and a[i + 1] == '10':
		res += 1
print(res + 1)


number = int(input())
data = []
magnet = 1
count = 0
while count < number:
	data.append(int(input()))
	count += 1
count = 0
while count < number - 1:
	if data[count] != data[count + 1]:
		magnet += 1
	count += 1
print(magnet)


a = int(input())
k = 0
v = []
for i in range(a):
	b = input()
	v.append(b)
	if v[i - 1] != v[i]:
		k += 1
print(k + 1)


magnetov = int(input())
pol = ''
skupin = 0
for i in range(magnetov):
	magnet = input()
	if magnet[1] != pol:
		pol = magnet[1]
		skupin += 1
print(skupin)


n = int(input())
out = 0
a = '00'
for i in range(n):
	b = input()
	if b != a:
		out += 1
	a = b
print(out)


n = int(input())
last_str = ''
value = 0
for i in range(n):
	curr_str = str(input())
	if last_str != curr_str:
		value += 1
	last_str = curr_str
print(value)


n = int(input())
a = {}
for i in range(n):
	a[i] = input()
m = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		pass
	else:
		m += 1
print(m)


n = int(input())
groups = 1
last = input()
for _ in range(n - 1):
	magnet = input()
	if magnet != last:
		groups += 1
		last = magnet
print(groups)


magnets_count = int(input(''))
current_state = None
blocks_count = 0
for i in range(0, magnets_count):
	state = input('')
	if current_state is None:
		blocks_count += 1
		current_state = state
	elif state != current_state:
		blocks_count += 1
		current_state = state
print(blocks_count)


n = int(input())
m = 1
curr = input()
for i in range(n - 1):
	t = input()
	if t != curr:
		m += 1
		curr = t
print(m)


n = int(input())
array = []
k = 1
hasil = 0
for i in range(n):
	magnet = input()
	array += [magnet]
for j in range(n):
	if k < len(array):
		if array[j] != array[k]:
			hasil += 1
		k += 1
print(hasil + 1)


n = int(input())
if n >= 1:
	nGroups = 1
else:
	nGroups = 0
prev = input()
for _ in range(n - 1):
	line = input()
	if line != prev:
		nGroups += 1
	prev = line
print(nGroups)


n = int(input())
l = list()
while n > 0:
	x = input()
	l.append(x)
	n -= 1
l = list(zip(l, l[1:]))
x = 1
for i in l:
	if i[0] != i[1]:
		x += 1
print(x)


(n, m) = (int(input()), 1)
x = []
for i in range(0, n):
	x.append(input())
for i in range(len(x) - 1):
	m1 = x[i]
	m2 = x[i + 1]
	if m1[1] == m2[0]:
		m += 1
print(m)


import sys
input = sys.stdin.readline
a = int(input())
i = 0
last = '00'
counter = 0
while i < a:
	b = input()
	if b != last:
		counter += 1
		last = b
	i = i + 1
print(counter)


total = int(input())
magnets = input()
atract = True
final = 1
for i in range(total - 1):
	p = magnets
	magnets = input()
	if p[1] == magnets[0]:
		atract = True
	else:
		atract = False
	if atract:
		final = final + 1
print(final)


n = int(input())
p = {}
for i in range(0, n):
	p[i] = input()
occ = 1
for i in range(0, n - 1):
	if p[i] != p[i + 1]:
		occ = occ + 1
print(occ)


n = int(input())
mag = []
gr = 1
for i in range(n):
	mag.append(int(input()))
for j in range(1, n):
	if mag[j] != mag[j - 1]:
		gr += 1
print(gr)


x = int(input())
l = []
for i in range(x):
	l.append(input())
k = 0
j = 0
t = []
for i in range(x - 1):
	if l[i] == '01':
		k += 1
		if l[i + 1] == '10':
			t.append(k)
			k = 0
	else:
		j += 1
		if l[i + 1] == '01':
			t.append(j)
			j = 0
if l[-1] == '01':
	k += 1
	t.append(k)
else:
	j += 1
	t.append(j)
print(len(t))


x = int(input())
y = ''
s = 0
while x != 0:
	y = y + input()
	x -= 1
z = ''
for i in y[1::2]:
	if i == z:
		continue
	else:
		s = s + 1
		z = i
print(s)


n = int(input())
G = 0
first = 0
for x in range(n):
	i = int(input())
	if first != i:
		G = G + 1
	first = i
print(G)


count = 1
num = input()
num = int(num) - 1
m1 = input()
for i in range(num):
	m2 = input()
	if m1 != m2:
		count += 1
	m1 = m2
print(count)


import sys
n = int(input())
g = 1
last = '__'
for s in sys.stdin.read().splitlines():
	if s[0] == last[-1]:
		g += 1
	last = s
print(g)


a = int(input())
b = [0] * a
counter = 0
for i in range(a):
	b[i] = int(input())
chosen = b[0]
for i in range(a):
	if chosen != b[i]:
		counter += 1
		chosen = b[i]
print(counter + 1)


num = int(input())
prevStr = ''
count = 0
for i in range(num):
	str = input()
	if str != prevStr:
		count += 1
	prevStr = str
if num == 1:
	print(1)
else:
	print(count)


(pocet, skupin, situacia) = (int(input()), 1, input())
for i in range(pocet - 1):
	magnet = input()
	if magnet != situacia:
		skupin += 1
		situacia = magnet
print(skupin)


n = int(input())
current = input()
groups = 1
i = 0
while i < n - 1:
	new = input()
	if new != current:
		groups += 1
	current = new
	i += 1
print(groups)


n = int(input())
list_ = []
for i in range(n):
	str_ = str(input())
	list_.append(str_)
count = 1
for j in range(n - 1):
	if list_[j] == list_[j + 1]:
		continue
	else:
		count = count + 1
print(count)


I = int(input())
M = []
for i in range(I):
	l = input()
	M.append(l)
count = 0
for i in range(I - 1):
	if M[i][1] == M[i + 1][0]:
		count += 1
print(count + 1)


n = int(input())
ar = []
while n > 0:
	ar.append(input())
	n -= 1
c = 1
for i in range(len(ar) - 1):
	if ar[i] != ar[i + 1]:
		c += 1
print(c)


n = int(input())
l = []
for i in range(n):
	l.append(input().rstrip())
cnt = 0
for i in range(n - 1):
	if l[i][1] == l[i + 1][0]:
		cnt += 1
print(cnt + 1)


n = int(input())
recent = '10'
groups = 0
for i in range(n):
	num = input()
	if i == 0:
		recent = num
		groups += 1
	elif num == recent:
		pass
	else:
		groups += 1
		recent = num
print(groups)


a = int(input())
b = []
c = 1
for x in range(a):
	b.append(input())
for y in range(1, a):
	if b[y - 1] != b[y]:
		c += 1
print(c)


def main():
	n = int(input())
	l = None
	c = 1
	for i in range(n):
		v = input().strip()
		if l is None:
			l = v[1]
			continue
		if v[0] != l:
			continue
		else:
			c += 1
			l = v[1]
	print(c)
main()


n = int(input().strip())
counter = 0
prev = -1
for i in range(n):
	mag = input().strip()
	if mag != prev:
		counter += 1
	prev = mag
print(counter)


n = int(input())
a = []
k = 1
s = str(input())
a.append(s)
for i in range(1, n):
	s = str(input())
	a.append(s)
	if a[i - 1] != a[i]:
		k = k + 1
print(k)


def magnets():
	n = int(input())
	string = ''
	count = 0
	for i in range(1, n + 1):
		value = input()
		string += value
	zeros = string.count('11')
	ones = string.count('00')
	result = zeros + ones
	if result > 0:
		print(result + 1)
	else:
		print(1)
magnets()


n = int(input())
s = [''] * n
for i in range(n):
	s[i] = input()
ret = 1
for i in range(1, n):
	if s[i - 1][1] == s[i][0]:
		ret += 1
print(ret)


n = int(input())
res = 0
for i in range(n):
	new = input()
	if i == 0:
		res = 1
		old = new
	else:
		if new != old:
			res += 1
		old = new
print(res)


n = int(input())
m = []
for _ in range(n):
	m.append(input())
flag = m[0][0]
i = 1
for el in m:
	if el[0] != flag:
		i += 1
		flag = el[0]
print(i)


total = int(input())
count = 1
pole_list = []
for i in range(total):
	magnets = input()
	pole_list.append(magnets[1])
for item in range(1, len(pole_list)):
	if pole_list[item] != pole_list[item - 1]:
		count += 1
print(count)


n = int(input())
grupos = 0
v = 0
for i in range(n):
	magnet = int(input())
	if magnet != v:
		grupos += 1
	v = magnet
print(grupos)


n = int(input())
mag = input()
count = 1
for i in range(1, n):
	d = mag
	mag = input()
	if d != mag:
		count += 1
print(count)


n = int(input(''))
i = 0
x = []
while i < n:
	x.append(int(input('')))
	i += 1
prev = x[0]
groups = 1
for i in x[1:]:
	if i != prev:
		prev = i
		groups += 1
print(groups)


n = int(input())
group = 1
a = [int(input())]
if n == 1:
	print(1)
else:
	i = 0
	while i <= n - 2:
		i += 1
		a.append(int(input()))
		if a[i] != a[i - 1]:
			group += 1
	print(group)


x = int(input())
b = ''
count = 1
for i in range(x):
	a = input()
	b += a[0]
c = b[0]
for i in range(len(b)):
	if c != b[i]:
		c = b[i]
		count += 1
print(count)


n = int(input())
prev = input()
count = 1
for _ in range(1, n):
	curr = input()
	if prev != curr:
		count += 1
	prev = curr
print(count)


magnets = int(input())
poles = []
groups = 1
for i in range(magnets):
	poles.append(input())
for i in range(1, magnets):
	if poles[i - 1][1] == poles[i][0]:
		groups += 1
print(groups)


n = int(input())
mag = []
ncount = 1
for i in range(n):
	mag.append(input())
for j in range(n - 1):
	if mag[j] == mag[j + 1]:
		pass
	else:
		ncount += 1
print(ncount)


prev = cnt = 0
for i in range(int(input())):
	cur = input()
	cnt += cur != prev
	prev = cur
print(cnt)


n = int(input())
a = ''
for _ in range(n):
	a += input()
grp = 1
for i in range(1, 2 * n):
	if a[i] == a[i - 1]:
		grp += 1
print(grp)


def magnets(arr, n):
	c = 1
	i = 0
	while i < n - 1:
		if arr[i] != arr[i + 1]:
			c += 1
		i += 1
	return c
n = int(input())
arr = []
for i in range(n):
	arr.append(input())
print(magnets(arr, n))


n = int(input())
list = []
count = 0
i = 0
for _ in range(n):
	list.append(input())
list.append('00')
while i < n:
	if list[i] == list[i + 1]:
		i = i + 1
	else:
		count = count + 1
		i = i + 1
print(count)


ct = 0
for i in range(int(input())):
	if i != 0:
		p = s[1]
	s = input()
	if i == 0:
		ct = 1
	elif p == s[0]:
		ct += 1
print(ct)


n = int(input())
prev = input()
count = 1
i = 1
while i < n:
	pres = input()
	if prev != pres:
		count += 1
	prev = pres
	i += 1
print(count)


def get_num_groups(l):
	cur = l[0]
	numGroups = 1
	for m in l[1:]:
		if m != cur:
			cur = m
			numGroups += 1
	return numGroups
n = int(input())
ip = []
for i in range(n):
	ip.append(input().strip())
print(get_num_groups(ip))


from sys import stdin

def main():
	n = int(stdin.readline()) - 1
	count = 0
	prev_s = stdin.readline()
	while n > 0:
		s = stdin.readline()
		if prev_s != s:
			count += 1
		prev_s = s
		n -= 1
	print(count + 1)
main()


cnt = 0
last = 0
n = int(input())
for i in range(n):
	cur = int(input())
	if cur != last:
		cnt += 1
		last = cur
print(cnt)


n = int(input())
last = '2'
if n:
	count = 1
else:
	count = 0
for i in range(n):
	domino = input()
	if last == domino[0]:
		count += 1
	last = domino[1]
print(count)


import sys
n = int(sys.stdin.readline())
x = sys.stdin.readline()
ans = 1
if n == 1:
	print(ans)
	exit()
for i in range(n - 1):
	x_new = sys.stdin.readline()
	if x_new[0] == x[1]:
		ans += 1
	x = x_new
print(ans)


a = int(input())
s = 1
b = input()
for i in range(a - 1):
	x = input()
	if b != x:
		s += 1
	b = x
print(s)


from sys import stdin
n = int(stdin.readline())
a = int(stdin.readline())
ans = 1
for i in range(n - 1):
	b = int(stdin.readline())
	if a != b:
		ans += 1
	a = b
print(ans)


cantidad = int(input())
megastring = ''
for i in range(cantidad):
	megastring += input()
grupos = 1
for i in range(len(megastring)):
	if i == len(megastring) - 1:
		break
	if megastring[i] == megastring[i + 1]:
		grupos += 1
print(grupos)


t = 0
inputa = int(input())
string = ''
for x in range(inputa):
	add = input()
	string += add
stringlen = len(string)
for char in range(stringlen - 1):
	if string[char] == string[char + 1]:
		t = t + 1
print(t + 1)


l = []
x = int(input(''))
for i in range(x):
	l.append(input(''))
c = 0
for i in range(x):
	if i < x - 1 and l[i] == l[i + 1]:
		i += 1
	else:
		c += 1
print(c)


n = int(input())
l = []
ostr = 1
for i in range(0, n):
	l.append(input())
	if l[i] != l[i - 1]:
		ostr += 1
print(ostr)


def answer():
	a = int(input())
	if a == 1:
		return 1
	c = input()
	ans = 1
	while a - 1:
		d = input()
		if d != c:
			ans += 1
			c = d
		a -= 1
	return ans
print(answer())


n = int(input())
L = []
y = 0
for i in range(n):
	L.append(input())
for x in range(len(L) - 1):
	if L[x] != L[x + 1]:
		y += 1
print(y + 1)


n = int(input())
c = ''
s = 1
for i in range(n):
	m = input()
	c += m
for j in range(len(c) - 1):
	if c[j] == c[j + 1]:
		s += 1
print(s)


numberOfGroups = 1
tail = ''
n = int(input())
for i in range(n):
	magnet = str(input())
	if n > 0:
		if magnet[0] == tail:
			numberOfGroups += 1
	tail = magnet[1]
print(numberOfGroups)


dim = input()
alist = []
for x in range(int(dim)):
	o = input()
	alist.append(o)
count = 1
len(alist)
for x in range(len(alist) - 1):
	if alist[x] != alist[x + 1]:
		count += 1
print(count)


def solve(arr):
	count = 0
	for i in range(1, len(arr)):
		if arr[i][0] == arr[i - 1][1]:
			count += 1
	count += 1
	return count

def main():
	n = int(input())
	arr = list()
	for _ in range(n):
		element = input()
		arr.append(element)
	print(solve(arr))
main()


n1 = int(input())
n = n1
count = 0
tmp = ''
while n:
	n -= 1
	s = input()
	if n is n1 - 1:
		count += 1
		tmp = s
		continue
	elif tmp != s:
		count += 1
		tmp = s
print(count)


ret = 0
prev = ''
for _ in range(int(input())):
	curr = input()
	if curr != prev:
		ret += 1
		prev = curr
print(ret)


N = input()
magnets = []
for i in range(int(N)):
	magnets.append(input())
islands = 1
count = 0
border = len(magnets) - 1
while True:
	if count == border:
		break
	elif magnets[count] == magnets[count + 1]:
		count += 1
		continue
	else:
		islands += 1
		count += 1
		continue
print(islands)


(n,) = map(int, input().split())
last = '2'
ans = 0
for i in range(n):
	s = input()
	if s[0] != last:
		ans += 1
	last = s[0]
print(ans)


n = int(input())
groups = 1
last = input()
for i in range(1, n):
	curr = input()
	if last != curr:
		groups += 1
	last = curr
print(groups)


n = int(input())
island = 0
last = str('0')
for i in range(n):
	m = input()
	if last != m:
		island += 1
	last = m
print(island)


a = int(input())
smt = []
for i in range(a):
	smt.append(int(input()))
k = 1
for i in range(a - 1):
	if smt[i] != smt[i + 1]:
		k += 1
print(k)


n = int(input())
last = int(input())
c = 1
for i in range(1, n):
	nl = int(input())
	if last != nl:
		c += 1
	last = nl
print(c)


n = int(input())
s = input()
q = s[0]
w = s[1]
r = 1
for i in range(1, n):
	s = input()
	if s[0] == w:
		r += 1
	w = s[1]
print(r)


g = []
for _ in range(int(input())):
	g.append(list(map(int, input().split())))
pre = g[0][0]
l = len(g)
res = 1
for i in range(1, l):
	if g[i][0] != pre:
		res += 1
	pre = g[i][0]
print(res)


x = int(input())
arr = []
for i in range(x):
	arr += input()
count = 1
for i in range(len(arr) - 1):
	if arr[i + 1] == arr[i]:
		count += 1
print(count)


from itertools import groupby
n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a[0])
m = 0
for i in groupby(l):
	m += 1
print(m)


n = int(input())
t = []
for i in range(n):
	t.append(str(input()))
a = ''.join(t)
a = a.replace('00', '0 0')
a = a.replace('11', '1 1')
print(len(a.split()))


def main():
	n = int(input())
	magnets = []
	for _ in range(n):
		magnets.append(int(input()))
	groups = 0
	prev = None
	for magnet in magnets:
		if magnet != prev:
			prev = magnet
			groups += 1
	print(groups)
main()


n = int(input())
count = 1
listMag = list()
for i in range(n):
	magnets = input()
	listMag.append(magnets)
for i in range(n - 1):
	if listMag[i] == listMag[i + 1]:
		pass
	else:
		count += 1
print(count)


n = int(input())
grp = 0
l = [input()]
while n - 1:
	l.append(input())
	n -= 1
for i in range(len(l) - 1):
	grp = grp + 1 if l[i] != l[i + 1] else grp
print(grp + 1)


n = int(input())
b = []
k = 1
for i in range(n):
	x = input()
	b.append(x)
for j in range(len(b) - 1):
	if b[j] != b[j + 1]:
		k += 1
print(k)


t = input()
t = int(t)
x = input()
t -= 1
x = int(x)
x = x % 10
prev = x
counter = 1
while t:
	temp = input()
	temp = int(temp)
	temp = temp % 10
	if temp != prev:
		counter += 1
		prev = temp
	t -= 1
print(counter)


n = int(input())
chain = ''
for i in range(n):
	chain += input()
cnt = 0
for i in range(1, 2 * n):
	if chain[i] == chain[i - 1]:
		cnt += 1
print(cnt + 1)


n = int(input())
(groups, i) = (0, 0)
current = input()
while i < n - 1:
	magnet = input()
	if current != magnet:
		groups += 1
	current = magnet
	i += 1
print(groups + 1)


n = int(input())
m = 1
label = input()
for i in range(n - 1):
	if label != input():
		label = label[::-1]
		m = m + 1
print(m)


n = int(input())
r = 0
prev = ''
for i in range(n):
	if i == 0:
		r += 1
		prev = input()
		continue
	curr = input()
	if curr[0] == prev[1]:
		r += 1
	prev = curr
print(r)


(ans, m) = (1, [])
for _ in range(int(input())):
	m.append(input())
for i in range(len(m) - 1):
	if m[i][0] == m[i + 1][-1]:
		ans += 1
print(ans)


from sys import stdin
n = int(stdin.readline())
x = stdin.readlines()
l = [i.strip() for i in x]
count = 1
for i in range(1, n):
	if l[i - 1][1] == l[i][0]:
		count += 1
print(count)


n = int(input())
prev = ''
groups = 0
for i in range(n):
	s = input()
	if s[0] == prev:
		groups += 1
	prev = s[1]
print(groups + 1)


numMagnets = int(input())
i = 0
groups = 1
magString = ''
while i < numMagnets:
	magIn = str(input())
	if magString.endswith('1') and magIn.startswith('1'):
		groups += 1
		magString += magIn
		i += 1
	elif magString.endswith('0') and magIn.startswith('0'):
		groups += 1
		magString += magIn
		i += 1
	else:
		magString += magIn
		i += 1
print(groups)


n = int(input())
l = []
count = 0
for i in range(0, n):
	a = int(input())
	l.append(a)
for j in range(0, len(l) - 1):
	if l[j] != l[j + 1]:
		count += 1
	else:
		count += 0
print(count + 1)


x = int(input())
if x == 1:
	print(1)
else:
	ans = 1
	w = []
	for _ in range(x):
		w.append(input())
	for i in range(1, len(w)):
		if w[i - 1] != w[i]:
			ans += 1
	print(ans)


from itertools import groupby
n = int(input())
s = ''
for i in range(n):
	k = input()
	if k == '01':
		s += 'a'
	else:
		s += 'b'
print(len([i for (i, j) in groupby(s)]))


n = int(input())
array = list()
b = 0
for x in range(n):
	a = str(input())
	array.append(a)
for x in range(0, n - 1):
	if array[x] != array[x + 1]:
		b += 1
print(b + 1)


n = int(input())
last = ''
cur = ''
count = 0
for x in range(n):
	cur = input()
	if cur != last:
		count += 1
	last = cur
print(count)


n = int(input())
s = ''
for v in range(n):
	t = input()
	s += t
print(1 + s.count('11') + s.count('00'))


n = int(input())
i = 0
previous = ''
ans = 0
while i < n:
	i = i + 1
	a = input()
	if a != previous:
		ans = ans + 1
		previous = a
print(ans)


n = int(input())
c = 1
prev_magnet = int(input())
for i in range(n - 1):
	next_magnet = int(input())
	if prev_magnet * next_magnet == 10:
		c += 1
	prev_magnet = next_magnet
print(c)


from sys import stdin, stdout
n = int(stdin.readline())
z = 0
prev = ''
for i in range(n):
	l = stdin.readline()
	if l != prev:
		z += 1
	prev = l
print(z)


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])
n = inp()
prev_end = None
num_groups = 0
for i in range(n):
	mag = insr()
	if not prev_end:
		prev_end = mag[-1]
		num_groups += 1
	else:
		head = mag[0]
		if head == prev_end:
			num_groups += 1
		prev_end = mag[-1]
print(num_groups)


import sys

def solve(input_path=None):
	if input_path is None:
		f = sys.stdin
	else:
		f = open(input_path, 'r')
	n = int(f.readline().rstrip())
	prev = None
	res = 1
	for i in range(n):
		magnet = f.readline().rstrip()
		if prev is not None:
			if magnet != prev:
				res += 1
		prev = magnet
	return [f'{res}']

def main():
	for line in solve():
		print(f'{line}')
main()


n = int(input())
l = []
f = []
c = 1
for i in range(n):
	s = input()
	l.append(s)
for i in range(len(l)):
	if i + 1 == len(l):
		continue
	if l[i] != l[i + 1]:
		c += 1
	else:
		f.append(c)
print(c)


n = int(input())
t = [input() for i in range(n)]
a = t[0]
cpt = 1
for e in t:
	if e != a:
		cpt += 1
		a = e
print(cpt)


arg = int(input())
prev = ''
res = 0
for a in range(0, arg):
	b = int(input())
	if b == prev:
		continue
	else:
		res += 1
	prev = b
print(res)


__author__ = 'myduomilia'
n = int(input())
s = ''
for i in range(n):
	val = input()
	s += val
print(1 + s.count('00') + s.count('11'))


number = int(input())
magnets = []
for x in range(number):
	magnet = input()
	magnets.append(magnet)
item = 0
groups = 0
while item < len(magnets):
	magnet = magnets[item]
	while magnets[item] == magnet:
		item += 1
		if item == len(magnets):
			break
	groups += 1
print(groups)


n = int(input())
prev = 0
counter = 0
for x in range(n):
	magnet = int(input())
	if magnet != prev:
		prev = magnet
		counter += 1
print(counter)


n = int(input())
a = []
a.append(input())
ans = 1
for i in range(1, n):
	t = input()
	if t != a[i - 1]:
		ans += 1
	a.append(t)
print(ans)


b = []
c = 1
for i in range(int(input())):
	a = int(input())
	b.append(a)
for x in range(len(b) - 1):
	if b[x] != b[x + 1]:
		c += 1
print(c)


__author__ = 'Utena'
n = int(input())
m = ''
for i in range(n):
	m += input()
t = 1
for i in range(2 * n - 1):
	if m[i + 1] == m[i]:
		t += 1
print(t)


from sys import stdin
n = int(stdin.readline())
res = 1
prev = None
for i in range(0, n):
	current = int(stdin.readline())
	if prev and prev != current:
		res += 1
	prev = current
print(res)


n = int(input())
x = ''
ost = 0
for i in range(n):
	a = str(input())
	if a != x:
		ost += 1
		x = a
print(ost)


n = int(input())
(group, y, z) = (0, [], [])
for _ in range(n):
	x = input()
	if x == '10':
		if z != []:
			z = []
			group += 1
		y.append(x)
	if x == '01':
		if y != []:
			y = []
			group += 1
		z.append(x)
print(group + 1)


n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
x = 0
cont = 0
while x < len(arr) - 1:
	x += 1
	cont += 1
	while arr[x] == arr[x - 1] and x < len(arr) - 1:
		x += 1
if arr[x] != arr[x - 1]:
	cont += 1
if cont == 0:
	print(1)
else:
	print(cont)


n = int(input())
s = ''
set = 1
space = ' '
for i in range(n):
	a = input()
	if s == '':
		s += a
	elif a[0] != s[-1]:
		s += a
	elif a[0] == s[-1]:
		set += 1
		s += space
		s += a
if n == 1:
	set = 1
print(set)


n = int(input())
br = 1
a = int(input())
for i in range(n - 1):
	x = a
	a = int(input())
	if x != a:
		br = br + 1
print(br)


n = int(input())
l = []
for i in range(n):
	s = input()
	s = s.strip()
	l.append(s)
sum = 1
for i in range(n - 1):
	if l[i] != l[i + 1]:
		sum += 1
print(sum)


n = int(input())
lst = []
answer = 1
for i in range(n):
	lst.append(int(input()))
for i in range(1, n):
	if lst[i] == lst[i - 1]:
		continue
	answer += 1
print(answer)


from sys import stdin
stdin.readline()
s = stdin.read()
print((len(s) - len(s.replace('0\n0', '').replace('1\n1', ''))) // 3 + 1)


s = []
n = int(input())
for i in range(n):
	si = input()
	s.append(si)
temp = ''
cont = 0
for si in s:
	if temp != si:
		cont += 1
		temp = si
print(cont)


n = int(input())
k = 0
s = 1
arr = [int(input()) for i in range(n)]
for i in range(len(arr) - 1):
	if arr[i] == arr[i + 1]:
		k += 1
	else:
		k = 0
		s += 1
print(s)


n = 0
magnet = '00'
for _ in range(int(input())):
	tmp = input()
	if tmp != magnet:
		n += 1
	magnet = tmp
print(n)


n = int(input())
row = ' '
while n > 0:
	magnet = input()
	if row[-1] != magnet[0]:
		row += magnet
	else:
		row += '-' + magnet
	n -= 1
answer = len(row.split('-'))
print(answer)


n = int(input())
a = []
for i in range(n):
	s = int(input())
	a.append(s)
i = 0
sum = 1
while i < len(a) - 1:
	if a[i] != a[i + 1]:
		sum += 1
	i += 1
print(sum)


n = int(input())
count = 1
t = input()
for i in range(0, n - 1):
	t1 = input()
	if t != t1:
		count = count + 1
	t = t1
if count != 0:
	print(count)


n = int(input())
st = input()
x = 1
for i in range(n - 1):
	s = input()
	if s == st:
		pass
	else:
		x += 1
		st = s
print(x)


n = int(input())
x = 1
ii = 0
l = []
while ii < n:
	aa = int(input())
	l.append(aa)
	ii += 1
for i in range(1, n):
	if l[i] != l[i - 1]:
		x += 1
print(x)


v = []
n = 0
m = 0
x = int(input())
if 1 <= x <= 100000:
	for z in range(x):
		c = input()
		if c == '10' or c == '01':
			v.append(c)
	if x == 1:
		print(1)
	else:
		for b in v:
			if v[n] != v[n + 1]:
				m = m + 1
			if n in range(len(v) - 2):
				n += 1
			else:
				break
		print(m + 1)


t = int(input())
l = []
for j in range(t):
	n = int(input())
	l.append(n)
c = 1
for i in range(t - 1):
	if l[i] != l[i + 1]:
		c += 1
print(c)


a0 = 2
count = 1
n = int(input())
for _ in range(n):
	a = int(input())
	if a // 10 == a0:
		count += 1
	a0 = a % 10
print(count)


n = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
c = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		pass
	else:
		c += 1
print(c)


n = int(input())
v = ''
grp = 0
for i in range(n):
	s = input()
	v = v + s
for j in range(len(v)):
	if v[j:j + 2] == '00':
		grp += 1
	elif v[j:j + 2] == '11':
		grp += 1
	else:
		pass
print(grp + 1)


n = int(input())
l = list()
for _ in range(n):
	x = input()
	if len(l) == 0:
		l.append(x)
	elif l[len(l) - 1][len(l[len(l) - 1]) - 1] != x[len(x) - 1]:
		l.append(x)
print(len(l))


n = int(input())
s = ''.join([input() for i in range(n)])
while s.find('00') >= 0 or s.find('11') >= 0:
	s = s.replace('00', 'k')
	s = s.replace('11', 'k')
print(len(s.split('k')))


def solution(magnets, n):
	if n == 0:
		return 0
	groups = 1
	for i in range(1, n):
		if magnets[i - 1] != magnets[i]:
			groups += 1
	return groups
n = int(input())
magnets = []
for _ in range(n):
	magnets.append(int(input()))
print(solution(magnets, n))


T = int(input())
nums = []
for i in range(T):
	nums.append(int(input()))
count = 1
for i in range(T - 1):
	if nums[i + 1] != nums[i]:
		count += 1
print(count)


try:
	l = []
	for i in range(int(input())):
		l.append(int(input()))
	p = 0
	for i in range(1, len(l)):
		if l[i] != l[i - 1]:
			p += 1
	print(p + 1)
except:
	pass


t = int(input())
c = []
l = []
for _ in range(t):
	s = input()
	l.append(s)
l = ''.join(l)
print(l.count('00') + l.count('11') + 1)


num = int(input())
line = ''
groups = 1
for i in range(num):
	line = line + str(input())
for i in range(num * 2 - 1):
	if line[i] == line[i + 1]:
		groups += 1
print(groups)


n = int(input())
t = n
magnets = list()
while t:
	magnets.append(input())
	t -= 1
group = 0
slider = magnets[0]
for i in range(1, n):
	if slider != magnets[i]:
		slider = magnets[i]
		group += 1
print(group + 1)


import enum

class Magnet(enum.Enum):
	A = '10'
	B = '01'

def handler(_input):
	counter = 1
	init = None
	for i in range(int(_input)):
		magnet = input()
		if init == None:
			init = magnet
		else:
			if magnet != init:
				counter += 1
			init = magnet
	return counter
print(handler(input()))


n = int(input())
l = []
f = 1
for i in range(n):
	t = input()
	l.append(t)
for i in range(n - 1):
	if l[i] != l[i + 1]:
		f += 1
print(f)


n = int(input())
prev = ''
res = 0
for i in range(n):
	magnet = input()
	if magnet != prev:
		res += 1
		prev = magnet
print(res)


n = int(input())
l = []
c = 0
for x in range(n):
	mp = input()
	l.append(mp)
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		c += 1
		flag = 1
	else:
		continue
print(c + 1)


num_magnets = int(input())
block_size = 0
total_blocks = 1
magnet_positions = [input() for x in range(num_magnets)]
current_block = magnet_positions[0]
for magnet in magnet_positions:
	if magnet == current_block:
		continue
	else:
		current_block = magnet
		total_blocks += 1
print(total_blocks)


number_of_magnet = int(input())
last_magnet = None
groups = 1
for _ in range(number_of_magnet):
	magnet = input()
	if last_magnet and last_magnet[1] == magnet[0]:
		groups += 1
	last_magnet = magnet
print(groups)


number = int(input())
last = ''
i = 0
group = 0
while i < number:
	aux = input()
	i += 1
	if aux != last:
		group += 1
		last = aux
print(group)


n = int(input())
b = int(input())
count = 1
for i in range(0, n - 1):
	comp = int(input())
	if comp != b:
		count += 1
		b = comp
print(count)


magnete = int(input())
ausrichtung = list()
anzahl = 1
for i in range(0, magnete):
	ausrichtung.append(input())
for i in range(0, magnete - 1):
	if ausrichtung[i] == ausrichtung[i + 1]:
		pass
	else:
		anzahl += 1
print(anzahl)


n = int(input())
ans = 1
x = input()
for q in range(n - 1):
	a = input()
	if x != a:
		ans += 1
		x = a
print(ans)


n = int(input())
a = input()
t = a[1]
sum = 0
for i in range(n - 1):
	a = input()
	if a[0] == t:
		sum += 1
		t = a[1]
	else:
		t = a[1]
print(sum + 1)


number = int(input())
alist = list()
alist.append(str(input()))
group = 1
for i in range(1, number):
	alist.append(str(input()))
	(a, b) = (alist[i], alist[i - 1])
	if a[0] != b[1]:
		continue
	else:
		group += 1
print(group)


n = int(input())
i = 0
count = 0
temp = 0
while i < n:
	x = int(input())
	if x != temp:
		count += 1
	temp = x
	i += 1
print(count)


d = int(input())
final = 0
streak = []
for i in range(d):
	zx = input()
	streak.append(zx)
for el in range(1, len(streak)):
	if streak[el - 1] != streak[el]:
		final += 1
print(final + 1)


numb = int(input())
grp = 0
former = ''
for i in range(numb):
	magnet = input()
	if magnet != former:
		grp += 1
	former = magnet
print(grp)


(a, c, u) = (int(input()), 1, input())
for i in range(a - 1):
	n = input()
	if n != u:
		c += 1
		u = n
print(c)


n = int(input())
magnets = []
Groups = 1
for i in range(n):
	magnet = input()
	magnets.append(magnet)
for j in range(1, n):
	if magnets[j] == magnets[j - 1]:
		continue
	elif magnets[j] != magnets[j - 1]:
		Groups += 1
print(Groups)


def Q27(lis):
	count = 1
	for i in range(1, len(lis)):
		if lis[i] != lis[i - 1]:
			count += 1
	return count
lis = []
n = int(input())
for i in range(n):
	line = int(input())
	lis.append(line)
print(Q27(lis))


def main():
	n = int(input())
	groups = 0
	magnet = None
	while n > 0:
		n -= 1
		_ = input()
		if _ != magnet:
			groups += 1
			magnet = _
	print(groups)
main()


magnet = int(input())
pre = ''
group = 0
for i in range(magnet):
	x = input().strip('\n\r')
	if x == pre:
		pre = x
	else:
		group += 1
		pre = x
print(group)


w = int(input())
a = []
t = 1
for i in range(0, w):
	p = input().split(' ')
	a.append(p)
for i in range(0, w - 1):
	if a[i] != a[i + 1]:
		t = t + 1
print(t)


(z, cnt) = (0, 0)
for i in range(int(input())):
	magn = int(input())
	if magn != z:
		cnt += 1
	z = magn
print(cnt)


n = int(input())
prev = input()
n = n - 1
count = 1
while n > 0:
	n = n - 1
	pres = input()
	if prev != pres:
		count += 1
		prev = pres
print(count)


n = int(input())
magList = []
groups = 1
for i in range(n):
	magList.append(input())
for i in range(0, n - 1):
	if magList[i][0] != magList[i + 1][0]:
		groups += 1
print(groups)


n = int(input())
lst = []
c = 1
for i in range(n):
	x = input()
	lst.append(x)
for i in range(len(lst) - 1):
	if lst[i] != lst[i + 1]:
		c = c + 1
print(c)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
n = ii()
sol = 1
(a, b) = (0, 0)
for i in range(n):
	s = si()
	if s == '10':
		if a == 0:
			a = 1
			sol += 1
			b = 0
	elif b == 0:
		b = 1
		sol += 1
		a = 0
print(sol - 1)


n = int(input())
a = []
for i in range(n):
	a.append(input())
g = 0
b = None
for i in a:
	if b != i:
		g += 1
		b = i
print(g)


matrix = []
num = 1
nn = int(input()) - 1
tmp = input()
for i in range(nn):
	now = input()
	if tmp[-1] == now[0]:
		num += 1
		tmp = now
print(num)


n = int(input())
x = 1
a = []
for i in range(n):
	a.append(str(input()))
for i in range(1, n):
	if a[i] != a[i - 1]:
		x += 1
print(x)


from sys import exit as sys_ret
magnets_bitch = int(input())
amount = 1
previous = input()
for _ in range(magnets_bitch - 1):
	new = input()
	amount += 1 if new[0] == previous[1] else 0
	previous = new
print(amount)


import sys
from copy import deepcopy

def main():
	inp = sys.stdin.readlines()
	if len(inp[1:]) == 1:
		print(1)
		return
	group = 0
	last_polar = None
	is_chain = False
	for mag in inp[1:]:
		for (idx, polarization) in enumerate(mag[:2]):
			if last_polar and idx == 0 and (last_polar != polarization):
				is_chain = True
			else:
				is_chain = False
			if is_chain is False and idx == 0:
				group += 1
		last_polar = deepcopy(polarization)
	print(group)
main()


n = int(input())
y = ''
l = 0
for i in range(n):
	x = input()
	y = y + x
n = len(y)
for i in range(n - 1):
	if y[i] == y[i + 1]:
		l = l + 1
print(l + 1)


n = int(input())
s = []
w = 0
for i in range(n):
	k = input()
	s.append(k)
for e in range(n):
	if e + 1 == n:
		break
	elif s[e] == s[e + 1]:
		continue
	else:
		w += 1
print(w + 1)


n = int(input())
s = input()
for i in range(1, n):
	temp = input()
	s = s + temp
divisions = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		divisions += 1
print(divisions + 1)


import sys
n = int(input())
ans = 1
s = input()
for i in range(1, n):
	m = sys.stdin.readline().strip()
	if s != m:
		ans += 1
	s = m
print(ans)


n = int(input())
arr = [input() for i in range(n)]
groups = 0
prev = None
i = 0
while i < n:
	if arr[i] != prev:
		groups += 1
	prev = arr[i]
	i += 1
print(groups)


a = int(input())
l = []
c = 0
for i in range(a):
	l.append(int(input()))
for i in range(a - 1):
	if l[i] == l[i + 1]:
		pass
	else:
		c += 1
print(c + 1)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
last_magnet = '00'
count = 0
for i in range(n):
	a = input()
	if a != last_magnet:
		count += 1
	last_magnet = a
print(count)


n = int(input())
parts = 1
last = input()[1]
for i in range(n - 1):
	magnet = input()
	parts += 0 if int(magnet[0]) ^ int(last) else 1
	last = magnet[1]
print(parts)


f = '00'
num = 0
for i in range(int(input())):
	m = input()
	if m != f:
		num += 1
		f = m
print(num)


t = int(input())
p = 0
c = 0
for _ in range(t):
	i = int(input())
	if i != p:
		c += 1
		p = i
print(c)


n = int(input())
a = [None] * n
ans = 1
for x in range(n):
	a[x] = list(input())
for x in range(n - 1):
	if a[x][1] == a[x + 1][0]:
		ans += 1
print(ans)


def func(arr):
	cnt = 1
	for i in range(len(arr) - 1):
		if arr[i] == arr[i + 1]:
			cnt += 1
	return cnt
n = int(input())
arr = []
for i in range(n):
	x = input()
	if x == '10':
		arr.append('-')
		arr.append('+')
	else:
		arr.append('+')
		arr.append('-')
print(func(arr))


(s, n) = (1, int(input()))
(a, b) = ('', input())
for i in range(1, n):
	a = input()
	s += int(a != b)
	b = a
print(s)


N = int(input())
counter = 1
i = 1
x = input()
while i < N:
	y = input()
	if x != y:
		counter += 1
	x = y
	i += 1
print(counter)


magnets = int(input())
magnetGroups = 0
lastMagnet = 0
for i in range(0, magnets):
	magnet = input()
	if magnet != lastMagnet:
		magnetGroups += 1
		lastMagnet = magnet
print(magnetGroups)


n = int(input())
previous_magnet = input()
groups = 1
for i in range(n - 1):
	magnet = input()
	if magnet != previous_magnet:
		previous_magnet = magnet
		groups += 1
print(groups)


n = int(input())
dec = []
tot = 1
for i in range(n):
	x = input()
	dec.append(x)
	if i > 0 and dec[i] != dec[i - 1]:
		tot += 1
print(int(tot))


n = int(input().rstrip())
if n == 1:
	print(1)
else:
	magnets = list()
	for m in range(n):
		magnets.append(input().rstrip())
	combined_magnet = ''.join(magnets)
	groups = 1
	for index in range(1, len(combined_magnet) - 1):
		if combined_magnet[index] == combined_magnet[index + 1]:
			groups += 1
	print(groups)


n = int(input())
q = n
if n == 1:
	x = int(input())
	print(1)
else:
	l = []
	count = 0
	while n:
		x = int(input())
		l.append(x)
		n = n - 1
	for i in range(len(l) - 1):
		if l[i] == l[i + 1]:
			count = count + 1
	print(q - count)


n = int(input())
x = 1
ci = input()
if n == 1:
	print(1)
else:
	for i in range(n - 1):
		a = input()
		if a != ci:
			x += 1
			ci = a
	print(x)


from sys import stdin
n = int(input())
pmag = '-1'
count = 0
for i in range(n):
	cell = stdin.readline()
	temp = cell[0]
	if temp != pmag:
		count += 1
	pmag = temp
print(count)


n = int(input())
group = 0
previous = 0
for i in range(n):
	position = int(input())
	if i == 0:
		group += 1
		previous = position
	elif position != previous:
		previous = position
		group += 1
print(group)


n = int(input())
magnets = [['', ''] for i in range(n)]
for i in range(n):
	m = list(input())
	magnets[i][0] = m[0]
	magnets[i][1] = m[1]
group_count = 0
for i in range(n):
	if i == 0:
		continue
	if magnets[i - 1][1] == magnets[i][0]:
		group_count += 1
print(group_count + 1)


rounds = int(input())
count = 1
old = input()
for i in range(1, rounds):
	new = input()
	if old != new:
		count = count + 1
	old = new[:]
print(count)


a = input()
a = int(a)
b = [0] * (a + 1)
otv = 0
b[0] = 'hui pizda ebala blad perastan ypotreblat'
for i in range(a):
	b[i + 1] = input()
for i in range(1, a + 1):
	if b[i] != b[i - 1]:
		otv += 1
print(otv)


number_of = int(input())
count_of_groups = 0
numb_temp = '0'
for i in range(number_of):
	input_temp = input()
	if not numb_temp == input_temp:
		count_of_groups += 1
		numb_temp = input_temp
print(count_of_groups)


n = int(input())
i = 0
lst = []
lst2 = []
while i < n:
	lst.append(input())
	i += 1
j = 0
while j < n - 1:
	if lst[j][1] == lst[j + 1][0]:
		lst2.append(1)
	j += 1
print(len(lst2) + 1)


x = int(input())
lst = []
for i in range(0, x):
	y = int(input())
	lst.append(y)
a = 0
temp = 1
for i in range(0, len(lst) - 1):
	if lst[i + 1] == lst[i]:
		temp = 1
	else:
		a += 1
print(a + 1)


n = int(input())
magnets = []
for _ in range(n):
	a = input()
	magnets.append(a)
count = 1
l = len(magnets)
for i in range(n):
	if i == l - 1:
		break
	if magnets[i] == '01' and magnets[i + 1] == '10':
		count += 1
	elif magnets[i] == '10' and magnets[i + 1] == '01':
		count += 1
	else:
		continue
print(count)


t = int(input())
d = []
while t > 0:
	t -= 1
	s = str(input())
	d += [s]
ans = 1
i = 0
while i < len(d) - 1:
	if d[i] == d[i + 1]:
		pass
	elif d[i] != d[i + 1]:
		ans += 1
	i += 1
print(ans)


n = int(input())
a = []
c = 1
for i in range(n):
	a.append(str(input()))
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		c += 1
print(c)


p = int(input())
s = []
c = 0
for i in range(0, p):
	l = int(input())
	s.append(l)
for j in range(0, p - 1):
	if s[j] != s[j + 1]:
		c = c + 1
print(c + 1)


n = int(input())
m = [input() for _ in range(n)]
ans = 1
for i in range(1, n):
	if m[i - 1] != m[i]:
		ans += 1
print(ans)


n = int(input())
mags = []
count = 0
for i in range(n):
	m = input()
	mags.append(m)
for j in range(len(mags) - 1):
	if mags[j] == '01' and mags[j + 1] == '01':
		count = count + 0
	elif mags[j] == '01' and mags[j + 1] == '10':
		count = count + 1
	elif mags[j] == '10' and mags[j + 1] == '10':
		count = count + 0
	elif mags[j] == '10' and mags[j + 1] == '01':
		count = count + 1
print(count + 1)


numberMagnets = int(input())
groups = 1
if numberMagnets == 1:
	print(1)
else:
	lastMag = str(input())
	for _ in range(numberMagnets - 1):
		currMag = str(input())
		if currMag != lastMag:
			groups += 1
		lastMag = currMag
	print(groups)


test = int(input(''))
sum = 0
count1 = 0
count2 = 0
p = 0
q = 0
l = list()
for i in range(0, test, 1):
	w = input('')
	l.append(w)
for i in l:
	if i == '10':
		count1 = count1 + 1
		if count2 > 0:
			count2 = 0
			q = q + 1
	if i == '01':
		count2 = count2 + 1
		if count1 > 0:
			count1 = 0
			p = p + 1
sum = p + q + 1
print(sum)


n = int(input())
a = ''
while n > 0:
	x = input()
	a += x
	n -= 1
a = a.replace('00', '0.0')
a = a.replace('11', '1.1')
c = a.split('.')
print(len(c))


a = input
c = b = 0
for i in ' ' * int(a()):
	s = a()
	c += s != b
	b = s
print(c)


n = int(input())
i = 0
l = []
c = 1
a = input()
temp = a
while i < n - 1:
	a = input()
	if temp != a:
		c = c + 1
	temp = a
	i = i + 1
print(c)


n = int(input())
arr = [input() for _ in range(n)]
groups = 1
start = arr[0]
for i in range(1, n):
	if arr[i] != start:
		groups += 1
		start = arr[i]
print(groups)


n = int(input())
group = 1
temp = int(input())
rem1 = temp % 10
for i in range(0, n - 1):
	x = int(input())
	rem = x % 10
	if rem != rem1:
		rem1 = rem
		group += 1
print(group)


number_of_magnets = int(input())
count = 1
previous_polarity = input()
for i in range(number_of_magnets - 1):
	polarity = input()
	if previous_polarity != polarity:
		count += 1
	previous_polarity = polarity
print(count)


def Magnets():
	n = int(input())
	row = []
	count = 1
	for i in range(n):
		row.append(input())
	for i in range(n - 1):
		if row[i][1] == row[i + 1][0]:
			count += 1
	print(count)
	return None

def main():
	Magnets()
main()


n = int(input())
res = ''
for i in range(n):
	res += input()
group = 1
group += res.count('00')
group += res.count('11')
print(group)


n_count = int(input())
first_value = input()
values = [int(first_value[0]), int(first_value[1])]
islands_count = 1
for i in range(1, n_count):
	value = input()
	(left, right) = [int(value[0]), int(value[1])]
	if left == values[i * 2 - 1]:
		islands_count += 1
	values.append(left)
	values.append(right)
print(islands_count)


n = int(input())
i = 1
list = []
while i <= n:
	a = input('')
	list.append(a)
	i = i + 1
list = ''.join(list)
b = len(list)
j = 0
c = 1
while j < b - 1:
	if list[j] == list[j + 1]:
		c = c + 1
		j = j + 1
	else:
		j = j + 1
print(c)


N = int(input())
a = '00'
res = 0
for i in range(N):
	y = input()
	if a != y:
		res += 1
	a = y
print(res)


x = int(input())
s1 = ''
p = 0
for i in range(0, x):
	s = input()
	s1 = s1 + s
for i in range(0, x * 2 - 1):
	if s1[i] == s1[i + 1]:
		p = p + 1
print(p + 1)


n = int(input())
text = input()
prev_state = text[0]
n -= 1
groups = 1
while n != 0:
	text = input()
	current_state = text[0]
	if current_state != prev_state:
		groups += 1
	prev_state = current_state
	n -= 1
print(groups)


t = int(input())
n = int(input())
count = 1
while t != 1:
	a = int(input())
	if n == a:
		pass
	else:
		count = count + 1
	n = a
	t = t - 1
print(count)


n = int(input())
ans = 1
key = input()
for i in range(1, n):
	if input() != key:
		ans += 1
		key = key[::-1]
print(ans)


n = int(input())
A = ''.join([input() for i in range(n)])
c = 0
for i in range(2 * n - 1):
	if A[i] == A[i + 1]:
		c += 1
print(c + 1)


n = int(input())
magnets = []
for i in range(n):
	magnets.append(input())
s = ''.join((str(i) for i in magnets))
print(s.count('00') + s.count('11') + 1)


a = int(input())
b = ''
c = 1
for x in range(a):
	d = input()
	b += d
for y in range(len(b) - 1):
	if b[y] == b[y + 1]:
		c += 1
print(c)


a = int(input())
i = 0
list = []
while i < a:
	list.append(input())
	i += 1
count = 0
ans = 1
while count < len(list) - 1:
	if list[count] == list[count + 1]:
		ans += 0
		count += 1
	else:
		ans += 1
		count += 1
print(ans)


n = int(input())
(res, cur) = (1, input())
for i in range(n - 1):
	s = input()
	if cur[-1] != s[0]:
		cur += s
	else:
		cur = s
		res += 1
print(res)


n = int(input())
r = input()
j = 0
for i in range(n - 1):
	s = input()
	if r != s:
		r = s
		j += 1
print(j + 1)


num_magnets = int(input())
lst = []
for i in range(num_magnets):
	lst.append(input())
group_cnt = 1
for i in range(num_magnets):
	if i != 0:
		if lst[i][0] == lst[i - 1][-1]:
			group_cnt += 1
print(group_cnt)


n = int(input())
c = 1
prev = 'aa'
s = 'bb'
for i in range(n):
	prev = s
	s = input()
	if prev[1] == s[0]:
		c += 1
print(c)


n = eval(input())
l1 = []
for a in range(n):
	l1.append(input())
i = 1
for m in range(n - 1):
	if l1[m] != l1[m + 1]:
		i = i + 1
print(i)


s = l = 0
for i in [0] * int(input()):
	x = input()
	if x != l:
		s += 1
	l = x
print(s)


num = int(input())
l = []
count = 0
for i in range(num):
	l.append(input())
for i in range(len(l) - 1):
	if int(l[i]) != int(l[i + 1]):
		count += 1
	else:
		count += 0
print(count + 1)


in1 = int(input())
prev = '22'
grp = 1
for i in range(in1):
	in2 = input()
	if in2[0] == prev[1]:
		grp = grp + 1
	prev = in2
print(grp)


n = int(input())
a = 1
pm = 2
mp = 2
for i in range(n):
	p = input()
	if p == '01' and pm == 1:
		pm = 0
		mp = 1
		a = a + 1
	elif p == '10' and mp == 1:
		pm = 1
		mp = 0
		a = a + 1
	elif p == '01':
		pm = 0
		mp = 1
	elif p == '10':
		pm = 1
		mp = 0
print(a)


n = int(input())
magnet = input()
left = True if magnet == '10' else False
groups = 1
for i in range(n - 1):
	magnet = input()
	if magnet == '10' and (not left):
		groups += 1
		left = not left
	elif magnet == '01' and left:
		groups += 1
		left = not left
print(groups)


n = int(input())
l = []
for i in range(n):
	m = input()
	l.append(m)
r = 1
for j in range(n - 1):
	if l[j] == l[j + 1]:
		r = r
	else:
		r += 1
print(str(int(r)))


from sys import stdin
(ans, c) = (0, '')
for _ in range(int(stdin.readline())):
	s = stdin.readline()
	if s != c:
		c = s
		ans += 1
print(ans)


n = int(input())
res = 1
x = input()
(a, b) = (int(x[0]), int(x[1]))
last = b
while n > 1:
	y = input()
	(c, d) = (int(y[0]), int(y[1]))
	if c == last:
		res += 1
	last = d
	n -= 1
print(res)


n = int(input())
groups = 1
for i in range(n):
	if i == 0:
		t = str(input())
	else:
		pos = str(input())
		if t != pos:
			groups += 1
			t = pos
print(groups)


a = int(input())
b = list()
count = 1
for i in range(0, a):
	c = int(input())
	b.append(c)
for i in range(1, a):
	if b[i] != b[i - 1]:
		count = count + 1
print(count)


lastType = ''
countgroup = 0
cases = int(input())
for i in range(cases):
	newMagnet = input()
	if newMagnet != lastType:
		countgroup += 1
		lastType = newMagnet
print(countgroup)


import sys
n = int(sys.stdin.readline().rstrip())
gr = 0
pre = 0
for _ in range(n):
	i = int(sys.stdin.readline().rstrip())
	if i != pre:
		gr += 1
		pre = i
print(gr)


no = int(input())
a = []
count = 0
for each in range(no):
	a.append(input())
for each in range(no - 1):
	if a[each] != a[each + 1]:
		count += 1
print(count + 1)


n = int(input())
c = 0
for i in range(n):
	if i == 0:
		prev = input()
		s = prev
		c = 1
	else:
		s = input()
		if s != prev:
			c += 1
			prev = s
print(c)


counter = 1
n = int(input())
tmp = input()
for x in range(n - 1):
	y = input()
	if tmp != y:
		counter += 1
		tmp = y
if counter != 0:
	print(counter)
else:
	print(1)


n = int(input())
flag = 0
count = 1
st = input()
if st[0] == '0':
	flag = 0
else:
	flag = 1
for tt in range(n - 1):
	st = input()
	if st[0] == '1' and flag == 0:
		count += 1
		flag = 1
	elif st[0] == '0' and flag == 1:
		count += 1
		flag = 0
print(count)


num_magnets = int(input())
prev_string = ''
num_groups = 0
for _ in range(num_magnets):
	magnet_in = input()
	if magnet_in != prev_string:
		num_groups += 1
	prev_string = magnet_in
print(num_groups)


n = int(input())
count = 1
c1 = input()
for _ in range(n - 1):
	c = input()
	if c1 != c:
		count += 1
	c1 = c
print(count)


n = int(input())
res = 0
cur = 'a'
for i in range(n):
	s = input()
	if s[0] == cur or cur == 'a':
		res += 1
	cur = s[1]
print(res)


ans = 1
for i in range(eval(input())):
	now = input()
	if i == 0:
		pre = now
		continue
	if now != pre:
		ans += 1
	pre = now
print(ans)


ans = 0
s = '00'
for i in range(int(input())):
	t = input()
	if s != t:
		ans += 1
		s = t
print(ans)


group = 0
n = int(input())
prev = 0
for i in range(n):
	current = int(input())
	if current != prev:
		group += 1
		prev = current
print(group)


from itertools import groupby
l = []
for x in range(0, int(input())):
	l.append(input())
print(len(list(groupby(l))))


n = int(input())
num = 1
curr = input()
for i in range(n - 1):
	prev = curr
	curr = input()
	if curr != prev:
		num += 1
print(num)


import math
n = int(input())
a = '2'
counter = 0
for i in range(n):
	b = input()[0]
	if b != a:
		a = b
		counter += 1
print(counter)


n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a)
i = 0
group = 1
while i < len(l) - 1:
	if l[i][1] == l[i + 1][0]:
		group += 1
	i += 1
if len(l) == 1:
	print(1)
else:
	print(group)


n = int(input())
start = ''
summa = 0
for i in range(n):
	a = input()
	if a != start:
		start = a
		summa += 1
print(summa)


n = int(input())
g = 0
b = '9'
for i in range(n):
	a = input()
	if a != b:
		g += 1
		b = a
print(g)


n = int(input())
w = []
s = 1
for i in range(1, n + 1):
	x = input()
	w.append(x)
for i in range(len(w) - 1):
	if w[i] != w[i + 1]:
		s += 1
print(s)


n = int(input())
p = []
c = 1
for i in range(n):
	m = input()
	p.append(m)
for i in range(len(p) - 1):
	if p[i][1] == p[i + 1][0]:
		c += 1
print(c)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
ans = 1
prev = None
for _ in range(int(input())):
	mlist = input()
	(a, b) = (int(mlist[0]), int(mlist[1]))
	if prev == None:
		prev = b
	else:
		if prev == a:
			ans += 1
		prev = b
print(ans)


(n, a, res) = (int(input()), '', 1)
for i in range(n):
	a += input()
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		res += 1
print(res)


groups = 1
for i in range(int(input().strip())):
	magnet = input().strip()
	if i == 0:
		pole = magnet[1]
	if magnet[1] != pole and i != 0:
		groups += 1
		if pole == '0':
			pole = '1'
		elif pole == '1':
			pole = '0'
print(groups)


b = str()
n = int(input())
for i in range(n):
	a = input()
	b = b + ''.join(a)
c = b.replace('00', '0 0')
d = c.replace('11', '1 1')
e = d.split(' ')
print(len(e))


a = int(input())
list = []
for i in range(a):
	list.append(input())
count = 1
for i in range(1, a):
	if list[i] == list[i - 1]:
		continue
	else:
		count = count + 1
		continue
print(count)


n = int(input())
o = 0
c = 0
for i in range(0, n):
	m = input()
	if n == 0:
		c += 1
	if o == m:
		pass
	else:
		c += 1
	o = m
print(c)


n = int(input())
count = 1
current_num = int(input())
for _ in range(n - 1):
	new_num = int(input())
	if current_num != new_num:
		count += 1
	current_num = new_num
print(count)


c = 0
h = ''
for i in ' ' * int(input()):
	t = input()
	if t != h:
		c += 1
	h = t
print(c)


n = int(input())
first = input()
count = 1
for i in range(1, n):
	second = input()
	if second != first:
		count += 1
	first = second
print(count)


n = int(input())
magnets = []
answ = 1
while n != 0:
	a = input()
	magnets.append(a)
	n -= 1
for i in range(0, len(magnets) - 1):
	if magnets[i] != magnets[i + 1]:
		answ += 1
print(answ)


n = int(input())
a = []
for i in range(0, n):
	b = int(input())
	a.append(b)
x = 1
for j in range(0, len(a) - 1):
	if a[j] == a[j + 1]:
		continue
	elif a[j] != a[j + 1]:
		x += 1
print(x)


n = int(input())
da = 0
a = [0] * n
for i in range(n):
	a[i] = int(input())
	if i > 0 and a[i] != a[i - 1]:
		da += 1
print(da + 1)


n = int(input())
magnets = ''
numOfMagnets = 1
for i in range(n):
	magnets += input()
for j in range(len(magnets) - 1):
	if magnets[j] is magnets[j + 1]:
		numOfMagnets += 1
print(numOfMagnets)


total_mag = input()
total_mag = int(total_mag)
mag_list = []
for i in range(total_mag):
	temp = input()
	mag_list.append(temp)
groups = 1
for i in range(0, len(mag_list) - 1):
	if not mag_list[i] == mag_list[i + 1]:
		groups += 1
print(groups)


n = int(input())
ar = []
for p in range(n):
	temp = input()
	ar.append(temp)
count = 0
ch1 = ar[0][1]
for i in range(1, n):
	if ch1 == ar[i][0]:
		count += 1
		ch1 = ar[i][1]
	else:
		ch1 = ar[i][1]
print(count + 1)


n = int(input())
pos = []
for _ in range(n):
	pos.append(input())
groups = 1
for i in range(1, n):
	if pos[i - 1][1] == pos[i][0]:
		groups += 1
print(groups)


n = int(input())
l = []
grp = 1
che = input()
for i in range(1, n):
	ch = input()
	if ch != che:
		grp += 1
	che = ch
print(grp)


num = int(input())
count = 1
before = input()
for i in range(1, num):
	magnet = input()
	if before != magnet:
		count += 1
	before = magnet
print(count)


n = int(input())
s = 1
e = int(input())
for i in range(n - 1):
	b = int(input())
	if b != e:
		s += 1
		e = b
print(s)


testCase = int(input())
numbers = [0]
count = 0
for i in range(1, testCase + 1):
	x = int(input())
	numbers.append(x)
for i in range(1, testCase + 1):
	if numbers[i - 1] != numbers[i]:
		count += 1
print(count)


N = int(input())
magents = []
for i in range(N):
	magents.append(input())
sol = []
tmp = []
for k in range(0, N):
	if k == N - 1:
		tmp.append(magents[k])
		sol.append(tmp)
		tmp = []
		break
	if magents[k] != magents[k + 1]:
		tmp.append(magents[k])
		sol.append(tmp)
		tmp = []
		continue
	tmp.append(magents[k])
print(len(sol))


n = int(input())
k = 1
s = input()
if n == 1:
	print(k)
else:
	for i in range(n - 1):
		ss = input()
		if ss != s:
			s = ss
			k += 1
	print(k)


l = int(input())
a0 = input()
c = l
for i in range(l - 1):
	a = input()
	if a == a0:
		c -= 1
	a0 = a
print(c)


t = int(input())
ls = []
for i in range(t):
	num = input()
	ls += (num,)
res = 1
for i in range(1, len(ls)):
	if ls[i - 1][1] == ls[i][0]:
		res += 1
print(res)


n = int(input()) - 1
M = input()
a = 1
for i in range(n):
	I = input()
	if I != M:
		a += 1
	M = I
print(a)


reizes = int(input())
ieprieksejais = 1230
rindas = 0
for i in range(reizes):
	sk = int(input())
	if sk != ieprieksejais:
		rindas = rindas + 1
		ieprieksejais = sk
print(rindas)


n = int(input())
s = 0
ostrov = 0
for i in range(n):
	magnit = input()
	s = str(s) + str(magnit)
	if s[len(s) - 4:len(s) - 2] != magnit:
		ostrov += 1
print(ostrov)


n = int(input())
a = []
z = 0
for i in range(1, n + 1):
	a.append(input())
	if i > 1:
		if a[i - 1] != a[i - 2]:
			z += 1
print(z + 1)


a = int(input())
s = list()
f = 1
for i in range(a):
	s.append(input())
for q in range(a - 1):
	if s[q] == '10' and s[q + 1] == '01':
		f += 1
	if s[q] == '01' and s[q + 1] == '10':
		f += 1
print(f)


prev = '_'
count = 1
for i in range(int(input())):
	a = input()
	if a[0] == prev:
		count += 1
	prev = a[1]
print(count)


n = int(input())
k = 1
kol = 1
last = input()
for i in range(n - 1):
	cur = input()
	if last == cur:
		continue
	else:
		kol += 1
	last = cur
print(kol)


def main():
	n = int(input())
	lst = 'kek'
	ans = 0
	for i in range(n):
		s = input()
		if s != lst:
			ans += 1
		lst = s
	print(ans)
main()


m = int(input())
ls = []
for i in range(m):
	x = input()
	ls.append(x)
count = 1
for i in range(len(ls) - 1):
	if ls[i] != ls[i + 1]:
		count += 1
	else:
		pass
print(count)


n = int(input())
str = ''
for x in range(0, n):
	str += input().strip()
print(str.count('00') + str.count('11') + 1)


c = 1
for i in range(int(input())):
	enter = input()
	if i > 0:
		if enter != last:
			c += 1
	last = enter
print(c)


n = int(input())
y = 0
c = 0
for x in range(n):
	a = input().split()
	if a != y:
		c += 1
	y = a
print(c)


import math
import os
import random
import re
import sys
n = int(input())
l = []
for x in range(n):
	c = int(input())
	l.append(c)
b = l[0]
n = 0
for y in l[1:]:
	if y != b:
		n = n + 1
		b = y
print(n + 1)


n = int(input())
ans = 0
l = '$$'
for _ in range(n):
	s = input()
	if s != l:
		ans += 1
		l = s
print(ans)


import sys
l = sys.stdin.readlines()[1:]
print(sum(map(lambda x, y: int(x != y), l, l[1:])) + 1)


n = int(input())
arr = []
counter = 1
for i in range(0, n):
	arr.append(input())
full = ' '.join([str(i) for i in arr])
full = full.replace(' ', '')
for i in range(1, len(full), 2):
	if i == len(full) - 1:
		break
	if full[i] == full[i + 1]:
		counter += 1
print(counter)


n = int(input())
i = 0
num = ''
group = 0
first = input()
data = first[1]
while i < n - 1:
	num = input()
	if data == num[0]:
		group += 1
	data = num[1]
	i += 1
print(group + 1)


n = int(input())
lst = []
groups = 1
for i in range(n):
	lst.append(input())
for i in range(n - 1):
	if lst[i] != lst[i + 1]:
		groups += 1
print(groups)


from heapq import heappush, heappop

def int_raw():
	return int(input())

def ss_raw():
	return input().split()

def ints_raw():
	return list(map(int, input().split()))
N = int_raw()
mgs = [input() for _ in range(N)]

def main():
	ans = 1
	prev = mgs[0]
	for idx in range(1, N):
		if prev != mgs[idx]:
			prev = mgs[idx]
			ans += 1
	return ans
print(main())


n = int(input())
counter = 0
huuuge_magnet = ''
for i in range(n):
	magnet = input().strip()
	huuuge_magnet += magnet
for i in range(0, len(huuuge_magnet) - 1):
	if huuuge_magnet[i] == huuuge_magnet[i + 1]:
		counter += 1
print(counter + 1)


a = int(input())
b = []
for r in range(0, a):
	c = input()
	b.append(c)
d = 1
for i in range(1, len(b)):
	if b[i] != b[i - 1]:
		d += 1
print(d)


n = int(input())
lst = []
for i in range(n):
	s = input()
	lst.append(s)
lst = ''.join(lst)
print(lst.count('0110') + lst.count('1001') + 1)


qtd = int(input())
vetor = []
for i in range(qtd):
	aux = int(input())
	vetor.append(aux)
contador = qtd
for i in range(len(vetor) - 1):
	if vetor[i] == vetor[i + 1]:
		contador -= 1
print(contador)


def groupofmagnets(s):
	groupcount = 1
	previ = ''
	for i in s:
		if i == previ:
			groupcount += 1
		previ = i
	return groupcount
n = int(input())
inputstr = ''
for i in range(0, n):
	inputstr += input()
print(groupofmagnets(inputstr))


n = int(input())
next = ''
groups = 0
for _ in range(n):
	previous = next
	next = input()
	if previous != next:
		groups += 1
print(groups)


m = [input() for i in range(int(input()))]
print(sum([m[i] != m[i + 1] for i in range(len(m) - 1)]) + 1)


n = input('')
magnetsList = []
groupCount = 0
for i in range(int(n)):
	magnetsList.append(input(''))
for j in range(int(n) - 1):
	if magnetsList[j][1] == magnetsList[j + 1][0]:
		groupCount += 1
groupCount += 1
print(groupCount)


n = int(input())
lst = ''
cnt = 1
for i in range(n):
	lst = lst + input()
for i in range(2, len(lst)):
	if lst[i] == lst[i - 1]:
		cnt += 1
print(cnt)


n = int(input())
a = str(input())
count = 1
while n - 1 > 0:
	b = str(input())
	if a != b:
		count += 1
	a = b
	n -= 1
print(count)


def solve():
	many = int(input())
	group = 1
	polar1 = 0
	polar2 = 0
	i = 0
	for _ in range(many):
		magnets = list(map(int, input()))
		if i == 0:
			polar1 = magnets[1]
		else:
			polar2 = magnets[0]
			if polar2 == polar1:
				group += 1
			polar1 = magnets[1]
			i = 0
		i += 1
	print(group)
solve()


n = int(input())
tmp = 2
count = 0
for i in range(n):
	s = input()
	if tmp == s[0]:
		count += 1
	tmp = s[1]
print(count + 1)


n = int(input())
c = []
r = 1
for i in range(n):
	a = input()
	c.append(a)
for b in range(len(c) - 1):
	if c[b] != c[b + 1]:
		r += 1
print(r)


a = int(input())
d = []
for i in range(a):
	d.append(input())
count = 0
b = d[0]
start = int(b[0])
for i in d:
	if int(i[0]) == start:
		count += 1
	start = int(i[1])
print(count)


(r, a) = (0, 'a')
for _ in range(int(input())):
	b = input()
	r += a != b
	a = b
print(r)


n = int(input())
l = []
for i in range(n):
	l.append(input())
s = ''.join(l)
group = 1
q = s[0]
for i in s[1:]:
	if i == q:
		group += 1
	q = i
print(group)


counter = 0
anterior = ''
n = int(input())
while n > 0:
	m = input()
	if m != anterior:
		counter += 1
	anterior = m
	n -= 1
print(counter)


n = int(input())
like_poles = 0
s = ''
for _ in range(n):
	s += input()
print(s.count('11') + s.count('00') + 1)


n = int(input())
m = []
for i in range(n):
	m.append(input())
m = ''.join(m)
count = 0
for i in range(0, len(m) - 1):
	if m[i] + m[i + 1] == '11' or m[i] + m[i + 1] == '00':
		count += 1
print(count + 1)


n = int(input())
ans = 1
k = []
for i in range(0, n):
	k.append(input())
for j in range(0, n - 1):
	if k[j] != k[j + 1]:
		ans += 1
print(ans)


n = int(input())
M = []
k = 1
for i in range(n):
	M.append(input()[:2])
for i in range(n - 1):
	if M[i] != M[i + 1]:
		k += 1
print(k)


n = int(input())
magnets = list()
count = 0
for _ in range(n):
	magnet = input()
	magnets.append(magnet)
for i in range(1, len(magnets)):
	if magnets[i - 1] != magnets[i]:
		count += 1
print(count + 1)


size = int(input())
ls = []
ln = 0
cou = 0
for i in range(size):
	ls.append(int(input()))
for i in range(len(ls) - 1):
	if ls[i] != ls[i + 1]:
		cou += 1
		ln = ls[i]
if ln == ls[-1]:
	print(cou)
else:
	print(cou + 1)


n = int(input())
l = list()
x = 1
for i in range(n):
	s = input()
	l.append(s)
for j in range(n - 1):
	if l[j] != l[j + 1]:
		x = x + 1
print(x)


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	current = 0
	groups = 0
	for _ in range(t):
		next = int(stdin.readline())
		if next != current:
			groups += 1
			current = next
	stdout.write(str(groups))
main()


mag = []
for _ in range(int(input())):
	mag.append(input())
grp = 1
for i in range(len(mag) - 1):
	if mag[i] != mag[i + 1]:
		grp += 1
print(grp)


n = int(input())
s = 1
p = input()
for i in range(n - 1):
	w = input()
	if w != p:
		s += 1
		p = w
print(s)


n = int(input())
sum = 1
l = []
for i in range(n):
	l.append(input())
i = 1
while i < n:
	if l[i] == l[i - 1]:
		q = 1
	else:
		sum += 1
	i += 1
print(sum)


n = int(input())
magnets = []
for i in range(n):
	x = input()
	magnets.append(x)
count_ = 1
for i in range(0, n):
	for j in range(i + 1, n):
		if magnets[i] == magnets[j]:
			break
		else:
			count_ += 1
			break
print(count_)


number_of_magnets = int(input())
number_of_groups = 1

def saving_list(n, list=[]):
	for i in range(n):
		polarity = input()
		list.append(polarity)
	return list
list = saving_list(number_of_magnets)
for i in range(len(list) - 1):
	if list[i] != list[i + 1]:
		number_of_groups += 1
print(number_of_groups)


n = int(input())
island = 0
domino = ''
for i in range(1, n + 1):
	magnet = input()
	if i == 1:
		domino = magnet
		island = 1
		continue
	if magnet[0] == domino[-1]:
		island += 1
	domino += magnet
print(island)


n = int(input())
latest = '00'
count = 0
for i in range(n):
	a = input()
	if a != latest:
		count += 1
		latest = a
print(count)


a = int(input())
lst = []
group = 1
for x in range(a):
	b = input()
	lst.append(b)
for x in range(a - 1):
	if x == a:
		break
	if lst[x][1] == lst[x + 1][0]:
		group += 1
	else:
		pass
print(group)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	ans = 0
	bef = '00'
	for _ in range(n):
		a = input().strip()
		if bef != a:
			ans += 1
		bef = a
	print(ans)
main()


a = int(input())
str = ''
for i in range(0, a):
	s = input()
	str += s
res = 1
for i in range(0, len(str) - 1):
	if int(str[i]) ^ int(str[i + 1]) == False:
		res = res + 1
print(res)


n = int(input())
tmp = ''
for i in range(n):
	tmp += input()
tmp = list(tmp)
count = 1
for i in range(len(tmp) - 1):
	if tmp[i] == tmp[i + 1]:
		count += 1
print(count)


n = int(input())
s = ''
for i in range(n):
	a = input()
	s = s + a
Len = len(s)
num = 0
for i in range(1, Len):
	if s[i] == s[i - 1]:
		num += 1
print(num + 1)


n = int(input())
sum = 1
k = str(input())
for i in range(n - 1):
	m = str(input())
	if m == k:
		continue
	else:
		sum += 1
	if m == '10':
		k = '10'
	else:
		k = '01'
print(sum)


(magnet_still, count) = ('', 0)
for _ in range(int(input())):
	magnet = input()
	if magnet != magnet_still:
		count += 1
		magnet_still = magnet
print(count)


numberOfMagnets = int(input())
previousMagnet = None
numberOfGroups = 1
for i in range(numberOfMagnets):
	currentMagnet = input()
	if previousMagnet == None:
		previousMagnet = currentMagnet
		continue
	else:
		if currentMagnet != previousMagnet:
			numberOfGroups = numberOfGroups + 1
		previousMagnet = currentMagnet
print(numberOfGroups)


f_input = int(input())
list = []
x = 0
groups = 1
for n in range(f_input):
	list.append(input())
n = 1
while x < f_input - 1:
	if list[x] == list[x + 1]:
		groups = groups
	else:
		groups = groups + 1
	x = x + 1
	n += 1
print(groups)


g = []
n = int(input())
g.append(int(input()))
pre = g[0]
res = 1
for _ in range(1, n):
	g.append(int(input()))
	if g[_] != pre:
		res += 1
	pre = g[_]
print(res)


n = int(input())
x = input()
cnt = 0
for _ in range(n - 1):
	y = input()
	if x != y:
		cnt += 1
	x = y
print(cnt + 1)


n = int(input())
c = 0
l = []
for i in range(n):
	s = input()
	l.append(s)
l = ''.join(l)
p = l.count('11') + l.count('00')
print(p + 1)


m = int(input())
test = 0
group = 0
for i in range(m):
	g_test = int(input())
	if test == 0:
		test = g_test
		group += 1
	elif test != g_test:
		group += 1
		test = g_test
print(group)


n = int(input())
count = 0
previous = ''
for i in range(n):
	a = input()
	if previous == '':
		count += 1
		previous = a
	elif a == previous:
		count = count
	elif a != previous:
		count += 1
		previous = a
print(count)


n = int(input())
prev = ''
cont = 0
for i in range(n):
	m = input()
	if m != prev:
		prev = m
		cont += 1
print(cont)


n = int(input())
if n == 0:
	print(0)
mag = int(input())
n -= 1
groups = 0
while n > 0:
	new_mag = int(input())
	if new_mag != mag:
		groups += 1
		mag = new_mag
	n -= 1
print(groups + 1)


lines = int(input())
one = input()
one = list(map(int, one))
sign = one[0]
group = 1
lines = lines - 1
while lines > 0:
	two = input()
	two = list(map(int, two))
	if two[0] != sign:
		sign = two[0]
		group = group + 1
	lines = lines - 1
print(group)


ip = int(input())
pole = '00'
count = 0
for i in range(ip):
	mag_poles = input()
	if mag_poles != pole:
		count += 1
		pole = mag_poles
print(count)


n = int(input())
magnet = list()
groups = 1
for i in range(0, n):
	s = input()
	magnet.append(s)
for i in range(0, n - 1):
	if magnet[i] != magnet[i + 1]:
		groups += 1
print(groups)


n = int(input())
res = 0
mag = 0
for _ in range(n):
	v = int(input())
	if mag != v:
		res = res + 1
		mag = v
print(res)


n = int(input())
aList = []
for i in range(n):
	aList.append(input())
k = 1
for i in range(n - 1):
	if aList[i] == aList[i + 1]:
		continue
	else:
		k += 1
print(k)


def main():
	ctr = 1
	n = int(input())
	s = input()
	for _ in range(n - 1):
		temp = input()
		if temp[0] != s[0]:
			ctr += 1
		s = temp
	print(ctr)
main()


cm = int(input())
am = 0
an = 0
amk = 0
ank = 0
for i in range(cm):
	k = int(input())
	if k == 10 and am == 0:
		am = am + 1
		amk = amk + am
		an = 0
	elif k != 10 and an == 0:
		an = an + 1
		ank = ank + an
		am = 0
print(amk + ank)


nb_magnets = int(input())
nb_group = 0
magnet2 = 0
for x in range(nb_magnets):
	magnet1 = magnet2
	magnet2 = input()
	if magnet1 != magnet2:
		nb_group += 1
print(nb_group)


s = ''
for i in range(int(input())):
	s += input()
r = 0
for i in range(len(s)):
	if i == 0:
		continue
	if s[i] != s[i - 1]:
		continue
	else:
		r += 1
print(r + 1)


import sys

def solve():
	n = int(input())
	ans = 0
	prev = ''
	for i in range(n):
		temp = input()
		if prev != temp:
			prev = temp
			ans += 1
	return ans
ans = solve()
print(ans)


n = int(input())
groups = 1
old_magnet = str(input()).zfill(2)
if n == 1:
	print(groups)
else:
	for i in range(n - 1):
		magnet = str(input()).zfill(2)
		if old_magnet[1] == magnet[0]:
			groups += 1
		old_magnet = magnet
	print(groups)


def main():
	num = int(input())
	lst = []
	for i in range(0, num):
		lst.append(input())
	count = 1
	for i in range(1, len(lst)):
		if lst[i] != lst[i - 1]:
			count += 1
	print(count)
main()


n = int(input())
a1 = input()
count = 0
for m in range(1, n):
	a2 = input()
	if a2 == a1:
		continue
	else:
		count += 1
		a1 = a2
print(count + 1)


n = int(input())
c = ''
d = 0
for i in range(n):
	b = input()
	if c != b:
		d = d + 1
	c = b
print(d)


n = int(input())
import sys
a = sys.stdin.readlines()
cnt = 1
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		cnt += 1
print(cnt)


magnets_n = int(input())
groups = 1
previous = input()
for _ in range(1, magnets_n):
	current = input()
	if previous[1] == current[0]:
		groups += 1
	previous = current
print(groups)


n = int(input())
br = 1
for i in range(0, n):
	a = str(input())
	if i > 0:
		if a[0] == b:
			br += 1
	b = a[1]
print(br)


number_of_magnets = int(input())
list1 = []
count = 1
for i in range(number_of_magnets):
	list1.append(int(input()))
temp = list1[0]
for i in range(len(list1)):
	if list1[i] != temp:
		count += 1
		temp = list1[i]
print(count)


n = int(input())
previous = None
groups = 0
for _ in range(n):
	m = input()
	if m != previous:
		previous = m
		groups += 1
print(groups)


n = int(input())
count = 0
prev = int(input())
for i in range(n - 1):
	nex = int(input())
	if nex != prev:
		count += 1
		prev = nex
print(count + 1)


import sys

def main():
	input_line = []
	for line in sys.stdin:
		input_line.append(line)
	count = 0
	for i in range(len(input_line)):
		if i == 0:
			continue
		elif int(input_line[i - 1]) - int(input_line[i]) == 0:
			continue
		else:
			count += 1
	if count == 0:
		count += 1
	print(count)
main()


n = int(input())
l = []
t = n
c = 0
j = 0
while n != 0:
	s = input()
	l.append(s)
	n = n - 1
for i in range(1, t):
	a = l[j]
	b = l[j + 1]
	if a[1] == b[0]:
		c = c + 1
	j = j + 1
print(c + 1)


n = int(input())
lis = [int(input()) for i in range(n)]
x = 0
new = [0]
for i in lis:
	if i != new[x]:
		new.append(i)
		x += 1
print(len(new) - 1)


t = int(input())
l = []
for i in range(t):
	l.append(input())
if len(l) == 1:
	print('1')
else:
	ct = 0
	for i in range(1, len(l)):
		if l[i] != l[i - 1]:
			ct += 1
	print(ct + 1)


n = int(input())
row = []
for i in range(n):
	row.append(input())
group = 1
for i in range(n - 1):
	if row[i + 1] != row[i]:
		group += 1
print(group)


magqty = int(input())
mgroups = 0
polarity1 = 0
for i in range(magqty):
	polarity2 = int(input())
	while polarity1 != polarity2:
		mgroups += 1
		polarity1 = polarity2
print(mgroups)


from sys import stdin
n = int(stdin.readline())
prev_input = '00'
k = 0
for i in range(n):
	current_input = stdin.readline()
	if current_input != prev_input:
		k += 1
	prev_input = current_input
print(k)


import re
n = int(input())
s = ''
for _ in range(n):
	s += input()
a = re.findall('00|11', s)
print(len(a) + 1)


def solve(arr, h):
	count = 1
	for i in range(1, int(h)):
		if arr[i] != arr[i - 1]:
			count += 1
	print(count)
h = input()
arr = list()
for i in range(int(h)):
	arr.append(input())
solve(arr, h)


n = int(input())
mas = []
s = 0
for i in range(n):
	mas.append(input())
for i in range(1, len(mas)):
	if mas[i - 1][1] == mas[i][0]:
		s += 1
print(s + 1)


n = int(input())
st = ''
counter = 0
for i in range(n):
	x = str(input())
	if st != '':
		if x[0] == st[-1]:
			counter += 1
	st += x
print(counter + 1)


temp = ''
cn = 0
for _ in ' ' * int(input()):
	x = input()
	cn += temp != x
	temp = x
print(cn)


b = '00'
c = 0
for _ in range(int(input())):
	a = input()
	if a != b:
		c += 1
	b = a
print(c)


N = int(input())
k = 1
Aux = int(input())
for i in range(1, N):
	Num = int(input())
	if Num != Aux:
		k += 1
	Aux = Num
print(k)


c = p = 0
for _ in ' ' * int(input()):
	chars = input()
	c += chars != p
	p = chars
print(c)


n = int(input())
d2 = input()
count = 1
for _ in range(n - 1):
	(d1, d2) = (d2, input())
	if d1[1] == d2[0]:
		count += 1
print(count)


n = int(input())
cc = bb = 0
for i in range(n):
	aa = int(input())
	if aa == bb:
		pass
	else:
		cc = cc + 1
		bb = aa
print(cc)


n = int(input())
magnets = []
for x in range(n):
	magnet = int(input())
	magnets.append(magnet)
count = 1
for x in range(len(magnets) - 1):
	if magnets[-x - 1] == magnets[-x - 2]:
		continue
	else:
		count += 1
print(count)


n = int(input().strip())
count = 1
left = input().strip()
for _ in range(1, n):
	right = input().strip()
	if left[1] == right[0]:
		count += 1
	left = right
print(count)


def main():
	n = int(input())
	x = 0
	somme = 0
	for i in range(n):
		nouv = int(input())
		if x != nouv:
			somme += 1
			x = nouv
	print(somme)
main()


n = int(input())
grp = 1
mgnt = []
for i in range(n):
	a = input()
	mgnt.append(a)
	if i > 0 and mgnt[i - 1] != a:
		grp += 1
print(grp)


n = int(input())
a = []
for i in range(n):
	a.append(input())
ans = 0
pre = a[0]
for i in a:
	cur = i
	if cur != pre:
		ans += 1
	pre = cur
print(ans + 1)


n = int(input())
p = ''
for x in range(n):
	p = p + input()
print(p.count('00') + p.count('11') + 1)


n = int(input())
l = []
g = 1
for i in range(n):
	l.append(str(input()))
for i in range(n - 1):
	if l[i + 1] != l[i]:
		g += 1
print(g)


a = int(input())
count = 0
lama = ''
baru = ''
for z in range(a):
	baru = input()
	if lama != baru:
		count += 1
	lama = baru
print(count)


a = input()
n = int(a)
magnets = [''] * n
for x in range(0, n):
	magnets[x] = input()
res = 1
aux = 1
for x in range(1, n):
	if magnets[x - 1] != magnets[x]:
		aux = aux + 1
	res = max(res, aux)
print(res)


from itertools import groupby
N = int(input())
L = [input() for i in range(N)]
M = list(groupby(L))
print(len(M))


s = ''
for _ in range(int(input())):
	s += input()
count = 1
i = 0
while i < s.__len__() - 1:
	if s[i] == s[i + 1]:
		count += 1
	i += 1
print(count)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
A = []
for i in range(N):
	A.append(input())
ans = 1
p = A[0]
for v in A[1:]:
	if v != p:
		ans += 1
		p = v
print(ans)


def main():
	n = int(input())
	sum = 0
	MAG = ''
	for _ in range(n):
		mag = input()
		if mag != MAG:
			sum += 1
			MAG = mag
		else:
			MAG = mag
	print(sum)
main()


num_of_magnets = int(input())
magnets = []
group = 1
for value in range(num_of_magnets):
	position_of_magnets = input()
	magnets.append(position_of_magnets)
for i in range(1, len(magnets)):
	if magnets[i] != magnets[i - 1]:
		group += 1
print(group)


def main():
	n = int(input())
	a = input()
	pr = a
	k = 1
	for i in range(1, n):
		a = input()
		if a != pr:
			k += 1
		pr = a
	print(k)
main()


n = int(input())
char = [0 for i in range(n)]
for i in range(n):
	char[i] = int(input())
output = 1
for i in range(n - 1):
	if char[i] == char[i + 1]:
		continue
	else:
		output += 1
print(output)


n = int(input())
x = 1
s = []
for m in range(n):
	m = int(input())
	s.append(m)
for i in range(len(s) - 1):
	if s[i] + s[i + 1] == 11:
		x += 1
print(x)


n = int(input())
l = []
(g, j) = (1, 0)
for i in range(n):
	l.append(input())
while j != len(l) - 1:
	if l[j] != l[j + 1]:
		g = g + 1
	j = j + 1
print(g)


def main():
	from sys import stdin, stdout
	state = ''
	counter = 0
	for _ in range(int(stdin.readline())):
		s = stdin.readline()
		if s != state:
			counter += 1
			state = s
	stdout.write(str(counter))
main()


u = int(input())
l = 0
y = int(input())
e = 0
for i in range(u - 1):
	j = y
	y = int(input())
	if y % 10 != j % 10:
		l += 1
print(l + 1)


i = int(input())
magnets = ''
for x in range(i):
	magnets += input()
s = 0
s += magnets.count('00') + magnets.count('11') + 1
print(s)


n = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
count = 1
for i in range(1, len(a)):
	if a[i - 1] == a[i]:
		continue
	else:
		count += 1
print(count)


n = int(input())
cnt = 1
b = []
for i in range(n):
	a = int(input())
	b.append(a)
for i in range(n - 1):
	if b[i] != b[i + 1]:
		cnt += 1
print(cnt)


n = int(input())
groups = 0
last_magnet = '00'
for i in range(n):
	x = input()
	if x != last_magnet:
		groups += 1
		last_magnet = x
print(groups)


n = int(input())
mags = []
for n in range(n):
	string = input()
	for digit in string:
		mags.append(digit)
j = 0
i = 1
groups = 1
while i < len(mags) - 1:
	if mags[i] == mags[i + 1]:
		groups += 1
	i += 2
print(groups)


def start(loop):
	result = []
	result_value = 1
	for i in range(int(loop)):
		result.append(input())
		if i >= 1:
			if result[i] != result[i - 1]:
				result_value += 1
	return result_value
print(start(input()))


n = int(input())
group = 1
l = []
for i in range(n):
	a = input()
	l.append(a)
for x in range(n - 1):
	if l[x] == l[x + 1]:
		group += 0
	else:
		group += 1
print(group)


n = int(input())
N = 1
a = 2
for i in range(n):
	s = str(input())
	x = s[0]
	y = s[1]
	if a == x:
		N = N + 1
		a = y
	else:
		a = y
		continue
print(N)


inp = int(input())
cont = 0
h = 0
for i in range(inp):
	v = input()
	if v == '10' and h == '01':
		cont += 1
		h = v
	if v == '01' and h == '10':
		cont += 1
		h = v
	if i == 0:
		cont += 1
		h = v
print(cont)


n = int(input())
string = ''
for i in range(n):
	string += input()
count = 1
for i in range(len(string) - 1):
	if string[i] == string[i + 1]:
		count += 1
print(count)


prev = 0
c = 0
for _ in range(int(input().strip())):
	magnet = int(input().strip())
	if magnet != prev:
		c = c + 1
		prev = magnet
	else:
		prev = magnet
print(c)


n = int(input())
MagnetLst = []
Magnets = 1
for i in range(n):
	Magnet = input()
	MagnetLst.append(Magnet)
for i in range(len(MagnetLst) - 1):
	if MagnetLst[i] != MagnetLst[i + 1]:
		Magnets += 1
print(Magnets)


row = int(input())
previous = 0
counter = 0
for i in range(0, row):
	current = int(input())
	if current != previous:
		counter += 1
	previous = current
print(counter)


hold = ''
for ___ in range(int(input())):
	hold += input()
print(hold.count('11') + hold.count('00') + 1)


qtd = int(input())
count = 1
text = ''
for _ in range(qtd):
	digitado = input()
	if text:
		if text[len(text) - 1] == digitado[0]:
			count += 1
	text += digitado
print(count)


lst = []
x = int(input())
a = 0
b = 0
c = 0
for i in range(0, x):
	a = int(input())
	if a != b:
		c += 1
		b = a
print(c)


a = int(input())
b = []
grp = 1
for i in range(a):
	x = int(input())
	b.append(x)
for j in range(a - 1):
	if b[j] == b[j + 1]:
		continue
	else:
		grp += 1
print(grp)


num_of_magnets = int(input())
num_of_groups = 1
magnet_group = []
for _ in range(num_of_magnets):
	magnet = input()
	magnet_group.append(magnet)
current_formation = magnet_group[0]
for magnet in magnet_group:
	if magnet != current_formation:
		num_of_groups += 1
		current_formation = magnet
print(num_of_groups)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	S = ''.join((input().rstrip() for _ in range(n)))
	print(S.count('00') + S.count('11') + 1)
main()


n = int(input())
ans = 1
prev = 1
tempx = input()
if tempx == '01':
	prev = 0
for i in range(1, n):
	temp = input()
	temp2 = 1
	if temp == '01':
		temp2 = 0
	if temp2 != prev:
		ans += 1
		prev = temp2
print(ans)


n = int(input())
groups = 1
z = int(input())
for _ in range(n - 1):
	x = int(input())
	if x != z:
		z = x
		groups += 1
print(groups)


n = int(input())
P = input()
N = 1
for i in range(n - 1):
	m = input()
	if m != P:
		N += 1
		P = m
print(N)


j = []
z = 1
x = int(input())
for i in range(x):
	j.append(input())
for r in range(x - 1):
	if j[r] != j[r + 1]:
		z += 1
print(z)


n = int(input())
no_of_grps = 0
magnet = ['01', '10']
magnet[0] = str(input())
for i in range(1, n):
	magnet[1] = str(input())
	if magnet[0][1] == magnet[1][0]:
		no_of_grps += 1
	magnet[0] = magnet[1]
print(no_of_grps + 1)


m = int(input())
mags = [input() for n in range(m)]
splits = 1
for i in range(1, len(mags)):
	if mags[i - 1] != mags[i]:
		splits += 1
print(splits)


n = int(input())
magnets = 1
s = input()
previous = s[-1]
for i in range(0, n - 1):
	s = input()
	if previous == s[0]:
		magnets += 1
	previous = s[-1]
print(magnets)


n = int(input())
s = []
num = 0
for i in range(n):
	s.append(input())
	if len(s) > 1 and s[-1][0] == s[-2][1]:
		num += 1
print(num + 1)


n = int(input())
a = input()
Sum = 1
for i in range(1, n):
	magnet = input()
	if magnet != a:
		a = magnet
		Sum += 1
print(Sum)


import sys
n = int(sys.stdin.readline().strip())
(groups, current) = (1, int(sys.stdin.readline().strip()))
for i in range(n - 1):
	s = int(sys.stdin.readline().strip())
	if s != current:
		groups += 1
		current = s
print(groups)


i = int(input())
l = []
for ele in range(i):
	l.append(input())
count = 1
for el in range(len(l) - 1):
	if l[el] != l[el + 1]:
		count += 1
print(count)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
cnt = 1
for i in range(n - 1):
	if l[i] != l[i + 1]:
		cnt += 1
print(cnt)


n = int(input())
l = []
count = 1
m = int(input())
l.append(m)
for i in range(1, n):
	m = int(input())
	l.append(m)
	if m != l[i - 1]:
		count += 1
print(count)


n = int(input(''))
i = 0
l = []
output = 1
while i < n:
	m = input('')
	l.append(m)
	if l[i] == l[i - 1]:
		output = output
		i += 1
	else:
		output = output + 1
		i += 1
print(output)


n = int(input())
(lista, ans) = ([], 0)
for i in range(n):
	s = input()
	lista.append(s)
for i in range(len(lista) - 1):
	if lista[i] != lista[i + 1]:
		ans += 1
print(ans + 1)


n = int(input())
all = str()
for i in range(1, n + 1):
	a = input()
	all = all + a
print(all.count('11') + all.count('00') + 1)


pre = -1
grp = 0
for i in range(int(input())):
	n = int(input())
	if n != pre:
		grp += 1
		pre = n
print(grp)


(a, res) = (11, 0)
for i in range(int(input())):
	b = input()
	if a != b:
		res += 1
		a = b
print(res)


n = int(input())
groups = 1
prev = 'Ahmed'
for _ in range(n):
	curr = input()
	if prev[-1] == curr[0]:
		groups += 1
	prev = curr
print(groups)


n = int(input())
magnets = []
sum = 1
for i in range(n):
	magnets.append(input())
for i in range(1, n):
	sum = sum + (magnets[i] != magnets[i - 1])
print(sum)


n = int(input())
g = 1
last = input()
for i in range(1, n):
	inn = input()
	if last != inn:
		g += 1
	last = inn
print(g)


a = int(input())
s = ''
for i in range(a):
	s += input()
sum = 0
for i in range(1, len(s)):
	if s[i] == s[i - 1]:
		sum += 1
print(sum + 1)


n = eval(input())
count = 1
lista = []
for i in range(n):
	lista += [input()]
for i in range(n - 1):
	if lista[i] != lista[i + 1]:
		count += 1
print(count)


n = int(input())
temp = 0
l = 0
for i in range(n):
	a = int(input())
	if temp != a:
		l += 1
	else:
		l = l
	temp = a
print(l)


def resolve(entradas):
	quant_groups = 1
	final = entradas[0][1]
	for entrada in entradas[1:]:
		if final == entrada[0]:
			quant_groups += 1
		final = entrada[1]
	return quant_groups
quant = int(input())
entradas = []
for i in range(quant):
	entradas.append(input())
print(resolve(entradas))


start = []
n = 1
for i in range(int(input())):
	start.append(input())
for i in range(1, len(start)):
	if not start[i - 1] == start[i]:
		n += 1
print(n)


n = int(input())
res = []
final = 1
i = input()
res.append(i)
for x in range(n - 1):
	i = input()
	res.append(i)
	if res[-2] != i:
		final += 1
print(final)


import sys
import itertools

def solve(xs):
	return sum((1 for _ in itertools.groupby(xs)))

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

def main():
	n = int(input())
	xs = [input().strip() for _ in range(n)]
	result = solve(xs)
	print(result)
main()


n = int(input())
lastMagnet = None
islandCount = 0
for i in range(n):
	newMagnet = input()
	if lastMagnet != newMagnet:
		islandCount += 1
		lastMagnet = newMagnet
print(islandCount)


n = int(input())
arr = []
for i in range(0, n):
	k = int(input())
	arr.append(k)
gr = 0
c = arr[0]
for i in range(1, n):
	if arr[i] == c:
		c = arr[i]
	else:
		gr += 1
		c = arr[i]
print(gr + 1)


n = int(input())
s = 0
ost = 0
for i in range(n):
	x = input()
	if x != s:
		s = x
		ost = ost + 1
print(ost)


a = int(input())
bef = int(input())
num = 1
for i in range(0, a - 1):
	af = int(input())
	if af != bef:
		num += 1
	bef = af
print(num)


import sys
list = []
for line in sys.stdin:
	tempstr = line.split()
	list.extend(tempstr)
list.pop(0)
k = 0
for i in range(0, len(list) - 1):
	if list[i] != list[i + 1]:
		k = k + 1
	else:
		continue
print(k + 1)


n = int(input())
last_s = ''
answer = 0
for i in range(n):
	s = input()
	if i == 0 or s != last_s:
		answer += 1
	last_s = s
print(answer)


n = int(input())
su = 1
ch = ''
for i in range(n):
	s = input()
	if s[0] == ch:
		su += 1
	ch = s[1]
if n == 0:
	print(0)
	quit()
print(su)


n = int(input())
a = list()
for i in range(n):
	a.append(input())
c = 1
for i in range(n - 1):
	if a[i][0] == a[i + 1][0]:
		continue
	else:
		c += 1
print(c)


n = int(input())
count = 1
mg1 = input()
oldr = mg1[1]
for i in range(n - 1):
	magnet = input()
	if oldr == magnet[0]:
		count += 1
	oldr = magnet[1]
print(count)


from sys import stdin
_input = stdin.readline
(_range, _int) = (range, int)

def solution():
	n = _int(_input())
	ans = 1
	old = _input()
	for _ in _range(1, n):
		s = _input()
		if old[1] == s[0]:
			ans += 1
		old = s
	print(ans)
solution()


n = int(input())
a = int(input())
i = 1
x = 0
while i <= n - 1:
	b = int(input())
	if b != a:
		x = x + 1
		a = b
	i = i + 1
print(x + 1)


n = int(input())
a = [[int(j) for j in input().split()] for i in range(n)]
q = 1
for i in range(n - 1):
	if a[i] != a[i + 1]:
		q += 1
print(q)


n = int(input())
m = []
for i in range(n):
	a = input()
	m.append(a)
s = ''.join(map(str, m))
res = s.count('00') + s.count('11') + 1
print(res)


n = int(input())
d = []
k = 0
l = 0
while n > 0:
	m = input()
	if m != k:
		l += 1
	k = m
	n -= 1
print(l)


n = int(input())
magnets = [int(input()) for i in range(n)]
sol = 0
for (i, ele) in enumerate(magnets):
	if i != len(magnets) - 1:
		if ele == magnets[i + 1]:
			continue
		sol = sol + 1
	else:
		sol = sol + 1
print(sol)


n = int(input())
nog = 0
for i in range(n):
	s = input()
	if i == 0:
		pi = s
		nog += 1
	if i > 0:
		if s != pi:
			nog += 1
			pi = s
print(nog)


t = int(input())
prev = int(input())
c = 0
while t > 1:
	n = int(input())
	if n != prev:
		c += 1
		prev = n
	t = t - 1
print(c + 1)


n = int(input())
pom = 1
pole = []
for i in range(n):
	pole.append([int(s) for s in input().split()])
	if pole[i] != pole[i - 1] and i > 0:
		pom += 1
print(pom)


n = int(input())
r = '  '
br = 1
l = []
for i in range(n):
	s = input()
	if s[0] == r[1]:
		br += 1
	r = s
print(br)


n = int(input())
arr = []
frag = 1
for i in range(n):
	arr.append(str(input()))
for k in range(1, len(arr)):
	if arr[k - 1][1] == arr[k][0]:
		frag += 1
print(frag)


n = int(input())
list1 = []
counter = 1
for i in range(n):
	list1.append(input())
for i in range(int(len(list1) - 1)):
	if list1[i] == list1[i + 1]:
		counter = counter
	else:
		counter += 1
print(counter)


noOfMagnets = int(input())
listOfMagnets = []
noOfGroupOfMagnets = 1
for i in range(noOfMagnets):
	listOfMagnets.append(input())
for i in range(1, len(listOfMagnets)):
	if listOfMagnets[i] != listOfMagnets[i - 1]:
		noOfGroupOfMagnets += 1
print(noOfGroupOfMagnets)


t = int(input())
l = [input() for i in range(t)]
c = 1
for i in range(t - 1):
	if l[i] != l[i + 1]:
		c += 1
print(c)


a = int(input())
z = 1
b = input()
for i in range(a - 1):
	d = input()
	if d != b:
		z = z + 1
	b = d
print(z)


n = int(input())
li = [input() for i in range(n)]
ans = 1
for i in range(1, n):
	ans += 1 if li[i] != li[i - 1] else 0
print(ans)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
ans = 1
s = input()
for i in range(n - 1):
	t = input()
	if s[-1] == t[0]:
		ans += 1
	s = t
print(ans)


n = int(input())
ans = 1
mn = 1
p = str(input())
for i in range(1, n):
	s = str(input())
	if p != s:
		ans += 1
	p = s
print(ans)


def input_magnets() -> str:
	n = int(input())
	result = ''
	for _ in range(n):
		result += input()
	return result

def count_groups(magnets: str):
	return magnets.count('00') + magnets.count('11') + 1
print(count_groups(input_magnets()))


n = int(input())
magnets = []
without_reps = []
for i in range(n):
	magnets.append(input())
	if i == 0:
		without_reps.append(magnets[i])
	elif without_reps[len(without_reps) - 1] != magnets[i]:
		without_reps.append(magnets[i])
print(len(without_reps))


n = int(input())
magnet = []
i = 0
while i < n:
	magnet.append(input())
	i = i + 1
k = 1
j = 0
while j < n - 1:
	if magnet[j][1] == magnet[j + 1][0]:
		k = k + 1
	j = j + 1
print(k)


n = int(input())
group = []
t = 0
while t < n:
	group.append(int(input()))
	t = t + 1
num = 1
for i in range(n):
	if i == n - 1:
		break
	if group[i] != group[i + 1]:
		num = num + 1
print(num)


s = ''
for _ in range(int(input())):
	s += input()
print(s.count('11') + s.count('00') + 1)


n = int(input())
cnt = 1
l = []
for i in range(n):
	x = input()
	l.append(x)
for i in range(0, len(l) - 1):
	if l[i] != l[i + 1]:
		cnt += 1
print(cnt)


n = int(input())
last = ''
cnt = 0
for _ in range(n):
	now = input()
	if now != last:
		cnt += 1
	last = now
print(cnt)


x = ''
for i in range(int(input())):
	x += input()
print(1 + x.count('00') + x.count('11'))


n = int(input())
counter = 1
list_ = []
for i in range(0, n):
	x = int(input())
	list_.append(x)
item = list_[0]
for i in list_:
	if i != item:
		counter += 1
		item = i
print(counter)


from itertools import groupby as t
l = []
for _ in range(int(input())):
	l.append(input())
count = 0
for (i, k) in t(l):
	count = count + 1
print(count)


n = input()
magnets = [input().split() for i in range(int(n))]
index = 0
count = 1
while index != int(n) - 1:
	if magnets[index] == magnets[index + 1]:
		count += 0
	else:
		count += 1
	index += 1
print(count)


n = int(input())
t = []
for i in range(n):
	x = input()
	t.append([int(x[0]), int(x[1])])
groups = 1
for i in range(len(t) - 1):
	if t[i][1] != t[i + 1][0]:
		pass
	else:
		groups += 1
print(groups)


magnets = int(input())
g = 1
m = input()
for _ in range(1, magnets):
	t = input()
	if t != m:
		g += 1
		m = t
print(g)


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
s = 1
for i in range(1, len(arr)):
	if arr[i - 1] == arr[i]:
		continue
	else:
		s = s + 1
print(s)


n = int(input())
arr = []
for i in range(n):
	num = int(input())
	arr.append(num)
count = 1
m = arr[0]
for j in range(n):
	if m == arr[j]:
		continue
	else:
		count += 1
		m = arr[j]
print(count)


def mangnet(l):
	count = 0
	s = l[0]
	s = s[1]
	for i in l[1:]:
		s1 = i[0]
		if s1 == s:
			count += 1
		s = i[1]
	return count + 1
n = int(input())
l = list()
for i in range(n):
	l.append(input())
print(mangnet(l))


n = int(input())
s = input()
c = 1
for v in range(n - 1):
	b = input()
	if s[1] == b[0]:
		c += 1
	s = b
print(c)


n = int(input())
arr = [str(input()) for i in range(n)]
arr1 = ''.join(arr)
print(arr1.count('11') + arr1.count('00') + 1)


n = int(input())
magnets = []
ele = 0
count = 0
for i in range(0, n):
	ele = int(input())
	magnets.append(ele)
for i in range(0, len(magnets) - 1):
	if magnets[i] != magnets[i + 1]:
		count += 1
print(count + 1)


num = int(input())
prev = 0
tot = 0
for _ in range(num):
	g = int(input())
	if g != prev:
		tot += 1
		prev = g
print(tot)


from sys import *
n = int(stdin.readline())
g = 1
a = stdin.readline()
n -= 1
l = a[1]
for i in range(n):
	x = stdin.readline()
	if l == x[0]:
		g += 1
	l = x[1]
print(g)


xyz = []

def input1():
	global xyz
	if len(xyz) == 0:
		xyz = [i for i in input().split()]
		xyz = xyz[::-1]
	v = xyz[-1]
	del xyz[-1]
	return v
x = int(input1())
y = []
for i in range(x):
	z = int(input1())
	y.append(z)
m = 1
for n in range(len(y) - 1):
	if y[n] != y[n + 1]:
		m = m + 1
print(m)


N = int(input())
K = []
G = 1
for i in range(0, N):
	K.append(int(input()))
for X in range(0, len(K) - 1):
	if K[X] != K[X + 1]:
		G += 1
print(G)


t = ''
n = int(input())
for i in range(1):
	t += input()
for j in range(n - 1):
	p = input()
	if p == t[-2:]:
		t += p
	else:
		t += ' ' + p
print(len(list(t.split(' '))))


n = int(input())
c = 0
d = 0
for i in range(n):
	a = int(input())
	if i == 0:
		d += 1
		if a % 10 != 0:
			c = 1
		else:
			c = 0
	else:
		if a // 10 == 1 and c == 1 or (a // 10 == 0 and c == 0):
			d += 1
		if a % 10 != 0:
			c = 1
		else:
			c = 0
print(d)


l = []
c = 1
for _ in range(int(input())):
	z = input()
	if _ == 0:
		l.append(z)
	elif z != l[-1]:
		l.append(z)
		c += 1
print(c)


n = int(input())
s = []
group = 0
for x in range(n):
	s += [input()]
for x in range(n - 1):
	if s[x][1] == s[x + 1][0]:
		group += 1
print(group + 1)


n = int(input(''))
groups = 1
lst = []
for i in range(n):
	x = input('')
	lst.append(x)
n = 0
for x in lst:
	try:
		if lst[n] != lst[n + 1]:
			groups += 1
		else:
			groups = groups
		n += 1
	except:
		break
print(groups)


holder = 0
timer = 0
for i in range(int(input())):
	l = int(input())
	if l != holder:
		holder = l
		timer += 1
print(timer)


n = int(input())
L = []
b = 1
for i in range(n):
	L.append(input())
for i in range(n - 1):
	if L[i] != L[i + 1]:
		b += 1
print(b)


n = int(input())
x = input()
n -= 1
sum = 1
while n:
	y = input()
	if x != y:
		sum += 1
		x = y
	n -= 1
print(sum)


import math
x = list(map(int, input().split()))
s = []
for i in range(0, x[0]):
	s.append(int(input()))
q = 1
if x[0] == 1:
	print(q)
else:
	for i in range(1, x[0]):
		if s[i] != s[i - 1]:
			q += 1
	print(q)


n = int(input())
lis = list()
for i in range(n):
	lis.append(input())
max = 1
count = 1
for i in range(n - 1):
	if lis[i] != lis[i + 1]:
		count += 1
print(count)


def number_of_groups_of_magnets(n, current_magnet):
	c = 1
	for m in range(1, n):
		magnet = input()
		if current_magnet != magnet:
			current_magnet = magnet
			c += 1
	return c
print(number_of_groups_of_magnets(int(input()), input()))


n = int(input())
num = 1
li = []
for i in range(n):
	li.append(input())
for i in range(1, n):
	if li[i] == li[i - 1]:
		num += 0
	else:
		num += 1
print(int(num))


n = int(input())
z = input()
sum = 0
n -= 1
while n:
	n -= 1
	x = input()
	if x != z:
		sum += 1
	z = x
print(sum + 1)


group = 0
prev = '-1'
for _ in range(int(input())):
	a = input()
	if a[0] == prev:
		group += 1
	prev = a[1]
print(group + 1)


n = int(input())
result = 1
cur = -1
for i in range(n):
	term = str(input())
	if term[0] == cur:
		result += 1
	cur = term[1]
print(result)


n = int(input().strip())
p = []
k = 1
for i in range(n):
	p.append(int(input().strip()))
	if p[len(p) - 1] != p[len(p) - 2]:
		k += 1
print(k)


n = int(input())
c = 0
for i in range(n):
	a = input()
	if i == 0:
		k = a[1]
		c = 1
	else:
		if k == a[0]:
			c += 1
		k = a[1]
print(c)


magnets = int(input()) - 1
current = int(input())
groups = 1
for _ in range(magnets):
	a = int(input())
	if a != current:
		groups += 1
		current = a
print(groups)


import sys

class Scanner:

	def __init__(self):
		self.current_tokens = []

	def remaining_tokens(self):
		return len(self.current_tokens)

	def nextline(self):
		assert self.remaining_tokens() == 0, 'Reading next line with remaining tokens'
		return input()

	def nexttokens(self):
		return self.nextline().split()

	def nexttoken(self):
		if len(self.current_tokens) == 0:
			self.current_tokens = self.nexttokens()
		assert self.remaining_tokens() > 0, 'Not enough tokens to parse.'
		return self.current_tokens.pop(0)

	def nextints(self, n=-1):
		if n == -1:
			return list(map(int, self.nexttokens()))
		else:
			return (self.nextint() for i in range(n))

	def nextint(self):
		return int(self.nexttoken())

def quit():
	sys.exit(0)
stdin = Scanner()
nextint = stdin.nextint
nextints = stdin.nextints
nextline = stdin.nextline
n = nextint()
m = 0
p = ''
for i in range(n):
	s = nextline()
	if s != p:
		m += 1
		p = s
print(m)


n = int(input())
count = 1
s = []
for i in range(n):
	b = input()
	s.append(b)
for j in range(1, n):
	if s[j - 1] == s[j]:
		continue
	else:
		count += 1
print(count)


n = int(input())
n0 = input()
i = 1
j = 1
while i < n:
	n1 = input()
	if n0 != n1:
		n0 = n1
		j += 1
	i += 1
else:
	print(j)


def solve():
	n = int(input())
	last = input()[1]
	k = 1
	for i in range(n - 1):
		x = input()
		if x[0] == last:
			k += 1
		last = x[1]
	print(k)
solve()


n = int(input())
last = '2'
group = 0
for t in range(n):
	x = input()
	if last == '2' or x[0] == last:
		group += 1
	last = x[1]
print(group)


n = int(input())
res = 1
prev = None
for i in range(n):
	mag = input()
	if prev is None:
		prev = mag
	if mag != prev:
		res += 1
	prev = mag
print(res)


islands = 1
n = int(input())
magnets = []
for i in range(n):
	magnets.append(int(input()))
for i in range(len(magnets[:-1])):
	if magnets[i] != magnets[i + 1]:
		islands += 1
print(islands)


n = int(input())
sets = 1
ip = input()
curr_or = ip
for _ in range(1, n):
	ip = input()
	if curr_or != ip:
		curr_or = ip
		sets += 1
print(sets)


n = int(input())
a = []
for x in range(n):
	a += input()
count = 1
for x in range(len(a) - 1):
	if a[x] == a[x + 1]:
		count += 1
print(count)


n = int(input())
cnt = 1
l = 0
for i in range(n):
	t = input()
	if not i:
		l = t[-1]
	elif t[0] == l:
		cnt += 1
		l = t[-1]
print(cnt)


x = int(input())
l = []
for i in range(x):
	z = int(input())
	l.append(z)
c = 0
l.append(c)
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		c += 1
print(c)


num = int(input())
list1 = []
for i in range(num):
	list1.append(input())
a = ''.join(list1)
print(a.count('00') + a.count('11') + 1)


n = int(input())
res = 0
prev = None
for i in range(n):
	a = int(input())
	if a != prev:
		res += 1
	prev = a
print(res)


x = [input() for i in range(int(input()))]
c = 0
for i in range(len(x) - 1):
	if x[i] == x[i + 1]:
		continue
	c += 1
print(c + 1)


n = int(input())
c = 1
li = []
for i in range(0, n):
	li.append(input())
res = li[0]
for i in li:
	if i != res:
		res = i
		c = c + 1
print(c)


t = int(input())
y = 'aa'
c = 0
for i in range(t):
	s = input()
	if s[0] == y[1]:
		c += 1
	y = s
print(c + 1)


g = p = 0
for i in range(int(input())):
	s = input()
	g += s != p
	p = s
print(g)


n = int(input())
s = 0
count = 0
while n > 0:
	a = int(input())
	if s != a:
		count += 1
	s = a
	n -= 1
print(count)


n = int(input())
k = 1
N = [0] * n
N[0] = input()
for i in range(1, n):
	N[i] = input()
	if N[i] != N[i - 1]:
		k += 1
print(k)


mags = int(input())
arrang = []
parts = 1
for i in range(mags):
	arrang += list(input())
for i in range(len(arrang) - 1):
	if arrang[i] == arrang[i + 1]:
		parts += 1
print(parts)


n = int(input())
l = []
m = 1
for i in range(n):
	s = input()
	l.append(s)
	if i > 0:
		if l[i - 1] == l[i]:
			continue
		else:
			count = 1
			m = m + 1
print(m)


n = int(input())
a1 = '0'
o = 0
a = '0'
for i in range(n):
	a1 = a
	a = input()
	if a1 == a:
		a1 = a
	else:
		o += 1
print(o)


import math
import os
import sys
import re
import itertools
import functools
import operator
res = ''
for _ in range(int(input())):
	res = res + input()
print(res.count('11') + res.count('00') + 1)


t = int(input())
pre = int(input())
c = 1
for i in range(t - 1):
	cur = int(input())
	if pre != cur:
		c += 1
	pre = cur
print(c)


n = int(input())
l = input()
z = 1
for i in range(n - 1):
	m = input()
	if l[1] == m[0]:
		z += 1
	l = m
print(z)


n = int(input())
string = ''
for i in range(n):
	string += input()
print(string.count('00', 0, len(string)) + 1 + string.count('11', 0, len(string)))


(n, t) = (int(input()), input())
for _ in range(n - 1):
	t_ = input()
	if t == t_:
		n -= 1
	else:
		t = t_
print(n)


n = int(input())
m = []
for i in range(n):
	a = str(input())
	m.append(a)
num = 1
for i in range(len(m) - 1):
	if m[i + 1] != m[i]:
		num += 1
print(num)


n = int(input())
lis = []
d = 0
for i in range(n):
	x = int(input())
	lis.append(x)
	if i != 0:
		if lis[i] != lis[i - 1]:
			d += 1
print(d + 1)


r = []
for i in range(int(input(''))):
	r += [input('')]
r = ' '.join(r)
print(r.count('1 1') + r.count('0 0') + 1)


n = int(input())
s = input()
k = 1
for i in range(n - 1):
	new_s = input()
	if s != new_s:
		k += 1
		s = new_s
print(k)


n = int(input())
prev = input()
g = 1
for i in range(n - 1):
	now = input()
	if prev != now:
		g += 1
	prev = now
print(g)


def main():
	n = int(input())
	m = input()
	g = 1
	for _ in range(n - 1):
		nxt = input()
		if nxt != m:
			g += 1
		m = nxt
	print(g)
main()


import sys
n = 0
p = 1
num = 0
cur = 0
for l in sys.stdin:
	if n == 0:
		iterations = int(l.strip())
		n = n + 1
	else:
		l = int(l.strip())
		if p <= iterations:
			p = p + 1
			if cur != l:
				num = num + 1
				cur = l
		else:
			break
print(num)


n = int(input())
num = 1
y = 0
x = input()
w = [x]
while y <= n - 2:
	x = input()
	w.append(x)
	if x == w[y]:
		pass
	else:
		num += 1
	y += 1
print(num)


mc = int(input())
(MAG, cx) = (input(), 1)
while mc != 1:
	mc -= 1
	mag = input()
	if MAG != mag:
		MAG = mag
		cx += 1
print(cx)


n = int(input())
a = []
for i in range(n):
	a.append(input())
c = 1
i = 1
while i < n:
	if a[i] != a[i - 1]:
		c += 1
	i += 1
print(c)


n = int(input())
z = 0
minus = '10'
plus = '01'
lis = []
for i in range(n):
	m = str(input())
	lis.append(m)
for j in range(len(lis) - 1):
	if lis[j] == lis[j + 1]:
		pass
	elif lis[j] != lis[j + 1]:
		z += 1
print(z + 1)


n = int(input())
a = []
for i in range(n):
	a.append(input())
a = ''.join(a)
c = a.count('11')
c2 = a.count('00')
print(c + c2 + 1)


n = int(input())
prev_pole = None
grps = 1
for i in range(n):
	p = input()
	if prev_pole and prev_pole == p[0]:
		grps += 1
	prev_pole = p[1]
print(grps)


try:
	n = int(input())
	x1 = int(input())
	count = 1
	for i in range(n - 1):
		x2 = int(input())
		if x2 != x1:
			count += 1
			x1 = x2
	print(count)
except:
	pass


n = int(input())
mlist = []
group = 1
for i in range(0, n):
	mlist.append(input())
for k in range(1, n):
	if mlist[k] != mlist[k - 1]:
		group += 1
print(group)


n = int(input())
c = 1
m = [''] * 2
m[0] = input()
for i in range(n - 1):
	m[1] = input()
	if m[1] == m[0]:
		continue
	else:
		c += 1
	m[0] = m[1]
print(c)


_list = [input() for _ in range(int(input()))]
print(1 + sum((x != y for (x, y) in zip(_list, _list[1:]))))


nb_magnets = int(input())
nb_group = 1
magnets = []
for x in range(nb_magnets):
	magnets.append(input())
for x in range(nb_magnets - 1):
	if magnets[x] != magnets[x + 1]:
		nb_group += 1
print(nb_group)


n = int(input())
p = []
same = 0
net = 0
for i in range(n):
	k = input()
	p.append(k)
	if i == 0:
		continue
	if k == p[-2]:
		same = 1
	else:
		net += 1
print(net + 1)


m = int(input())
group = 1
magnets = ''
for item in range(m):
	mag = input()
	magnets += mag
for item in range(len(magnets) - 2):
	if magnets[item] == magnets[item + 1]:
		group += 1
print(group)


n = int(input())
lst = []
k = 1
for i in range(n):
	n1 = int(input())
	lst.append(n1)
for j in range(len(lst) - 1):
	if lst[j] == lst[j + 1]:
		continue
	k = k + 1
print(k)


ans = 1
n = int(input())
prev = input()
for _ in range(n - 1):
	curr = input()
	if prev[-1] == '0' == curr[0] == '0':
		ans += 1
	if prev[-1] == '1' and curr[0] == '1':
		ans += 1
	prev = curr
print(ans)


n = int(input())
prev_dom = ''
count = 0
for i in range(n):
	new_dom = input()
	if not prev_dom == new_dom:
		count += 1
	prev_dom = new_dom
print(count)


n = int(input())
count = 0
magnet_tail = ''
for i in range(n):
	magnet = input()
	if magnet_tail == '':
		magnet_tail = magnet[1]
		count += 1
	elif magnet_tail == magnet[0]:
		magnet_tail = magnet[1]
		count += 1
print(count)


x = int(input())
l = []
for i in range(x):
	l.append(input())
total = 0
t = 0
for i in range(x):
	if l[i] != t:
		total = total + 1
		t = l[i]
print(total)


n = int(input())
blocks = []
for _ in range(n):
	blocks.append(input())
ans = 1
for i in range(1, n):
	if blocks[i] != blocks[i - 1]:
		ans += 1
print(ans)


n = int(input())
list = []
for i in range(n):
	x = input()
	if x == '01':
		a = 0
		b = 1
	else:
		a = 1
		b = 0
	list.append(a)
	list.append(b)
result = 1
if len(list) == 1:
	print(result)
for i in range(len(list) - 1):
	if list[i] == list[i + 1]:
		result += 1
print(result)


magnets = int(input())
groups = 1
end = input()
for i in range(1, magnets):
	magnet = input()
	if end[1] == magnet[0]:
		groups += 1
	end = magnet
print(groups)


n = int(input())
face = [input() for i in range(n)]
end = 0
group = 0
for i in range(n - 1):
	if face[end] == face[end + 1]:
		end += 1
	else:
		group += 1
		end += 1
group += 1
print(group)


a = int(input())
c = []
g = 0
for i in range(a):
	d = input()
	c.append(d)
for i in range(1, len(c)):
	if c[i - 1] != c[i]:
		g += 1
	else:
		continue
print(g + 1)


n = int(input())
p = a = e = i = 0
while i < n:
	s = str(input())
	if s == '10':
		a = 1
	else:
		a = 2
	if e != a:
		p += 1
	e = a
	i += 1
print(p)


import sys
mag = ''.join(list(map(lambda x: x.strip('\n'), sys.stdin.readlines()[1:])))
print(mag.count('00') + mag.count('11') + 1)


n = int(input())
l = []
for i in range(n):
	x = input()
	l.append(x)
g = 1
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		g += 1
print(g)


n = int(input())
current = input()
groups = 1
for x in range(1, n):
	next = input()
	if next[0] == current[1]:
		groups += 1
	current = next
print(groups)


from collections import Counter

def check(mg):
	c = 1
	for i in range(1, len(mg)):
		if mg[i] != mg[i - 1]:
			c += 1
	return c
n = int(input())
mg = []
for i in range(n):
	mg.append(input())
print(check(mg))


n = int(input())
a = []
for i in range(n):
	a.append(input())
print(sum((a[i] != a[i + 1] for i in range(n - 1))) + 1)


n = int(input())

def solve(n):
	counter = 0
	b = 0
	for i in range(0, n):
		a = input()
		if a != b:
			counter += 1
		b = a
	print(counter)
solve(n)


c = 0
for i in range(int(input())):
	if i != 0:
		cm = input()
		if cm != pm:
			c += 1
		pm = cm
	else:
		pm = input()
		c += 1
print(c)


from sys import stdin
n = int(stdin.readline())
s = stdin.readline()
i = 0
count = 0
while i < n - 1:
	m = stdin.readline()
	if s[1] == m[0]:
		count += 1
		s = m
	i = i + 1
print(count + 1)


n = int(input())
groups = 1
poles_grp = None
for i in range(n):
	poles = input()
	if poles_grp == None:
		poles_grp = poles
	elif poles_grp[-1] == poles[0]:
		groups = groups + 1
		poles_grp = poles_grp + poles
print(groups)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
answer = 1
for _ in range(int(data())):
	if _ == 0:
		last = data()
		continue
	temp = data()
	if temp != last:
		answer += 1
	last = temp
out(answer)


inp1 = input()
l = []
count = 1
for num in range(int(inp1)):
	inp2 = input()
	l.append(inp2)
x = l[0]
for lis in l:
	if lis == x:
		continue
	else:
		count += 1
		x = lis
print(count)


T = int(input())
count = 1
s = ''
for i in range(T):
	x = input()
	if s == '':
		s = s + x
	else:
		if s[-1] != x[0]:
			count = count
		else:
			count = count + 1
		s = s + x
if count == 0:
	print(1)
else:
	print(count)


def magnet(n):
	result = 1
	curr = input()
	for i in range(n - 1):
		nxt = input()
		if curr != nxt:
			result += 1
		curr = nxt
	return result

def main():
	n = int(input())
	print(magnet(n))
main()


n = int(input())
a = []
for i in range(n):
	a.append(input())
num = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		continue
	else:
		num += 1
print(num)


class Node:
	data = None
	prev_element = None
	next_element = None

	def __init__(self, data):
		self.data = data
		self.next_element = Node
		self.prev_element = Node

class Stack:

	def __init__(self):
		self.tail = Node
		self.size = 0

	def push(self, data):
		node = Node(data)
		self.size += 1
		if self.tail is None:
			self.tail = node
		else:
			self.tail.next_element = node
			node.prev_element = self.tail
			self.tail = node

	def top(self):
		return self.tail.data

	def pop(self):
		self.size -= 1
		if self.tail:
			self.tail = self.tail.prev_element
			if self.tail:
				self.tail.next_element = None

	def empty(self):
		if self.tail:
			return False
		return True

	def get_size(self):
		print(self.size)
		return self.size
n = int(input())
s = Stack()
count = 0
for i in range(n):
	x = input()
	if s.top() != x:
		count += 1
	s.push(x)
print(count)


n = int(input())
c = input()
ct = 1
s = c
for i in range(n - 1):
	c = input()
	if c != s:
		ct += 1
		s = c
	else:
		c = s
print(ct)


vss = ric = -1
for i in open(0):
	ric += vss != i
	vss = i
print(ric)


size = int(input())
counter = 0
prev = -1
for i in range(size):
	x = int(input())
	if x != prev:
		counter += 1
		prev = x
print(counter)


cnt = 1
last = None
for _ in range(int(input())):
	s = input()
	if last == None:
		last = s
	elif last != s:
		cnt += 1
	last = s
print(cnt)


n = int(input())
i = 0
qwerty = 0
p = input()
while n - 1 > i:
	s = input()
	if p[1] == s[0]:
		qwerty = qwerty + 1
	p = s
	i = i + 1
qwerty = qwerty + 1
print(qwerty)


n = int(input())
l = int(input())
c = 1
for _ in range(n - 1):
	m = int(input())
	if m != l:
		c += 1
		l = m
print(c)


n = int(input())
l = []
for i in range(n):
	l.append(str(input()))
c = 0
sym = l[0]
for i in range(n):
	if sym != l[i]:
		sym = l[i]
		c += 1
print(c + 1)


n = int(input())
c = 1
ar = []
for i in range(n):
	k = int(input())
	ar.append(k)
	if i > 0:
		if ar[-2] != ar[-1]:
			c += 1
print(c)


from sys import stdin
from collections import defaultdict as dd
n = int(stdin.readline().rstrip())
l = []
for i in range(n):
	p = stdin.readline().rstrip()
	l.append(p)
c = 1
for i in range(n - 1):
	if l[i][1] == l[i + 1][0]:
		c += 1
print(c)


n = int(input())
total = 1
for i in range(n):
	magnet = input()
	if i == 0:
		previous = magnet[1]
	else:
		if magnet[0] in previous:
			total += 1
		else:
			None
		previous = magnet[1]
print(total)


n = int(input())
l = []
z = []
count = 0
for i in range(n):
	l.append(input())
if n == 1:
	print('1')
else:
	for i in range(n):
		if i + 1 == n:
			count += 1
			z.append(count)
		else:
			y = l[i]
			x = l[i + 1]
			if y[1] != x[0]:
				count += 1
			else:
				z.append(count)
				count = 0
	print(len(z))


T = int(input())
a = []
while T > 0:
	T = T - 1
	a.append(int(input()))
count = 1
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		count = count + 1
print(count)


n = int(input())
num1 = []
for i in range(n):
	s = str(input())
	num1.append(s)
a = 1
for i in range(1, n):
	if num1[i] != num1[i - 1]:
		a += 1
	else:
		continue
print(a)


n = int(input())
magnets = []
group = []
if n == 1:
	dummy = input()
	print(1)
else:
	for i in range(n):
		magnets.append(input())
	for y in range(len(magnets) - 1):
		if magnets[y][1] == magnets[y + 1][0]:
			if not group:
				group.append(magnets[y])
				group.append(magnets[y + 1])
			else:
				group.append(magnets[y + 1])
		elif not group:
			group.append(magnets[y] + magnets[y + 1])
		else:
			group.append(group.pop(-1) + magnets[y + 1])
	print(len(group))


n = int(input())
a = [int(input()) for i in range(n)]
c = 0
b = 0
for i in range(n):
	if a[i] == b:
		continue
	else:
		c += 1
		b = a[i]
print(c)


n = int(input())
counter = 0
m = 0
k = ''
for i in range(0, n):
	m = input()
	if not k == m:
		counter += 1
		k = m
print(counter)


a = int(input())
list = []
cnt = 0
while len(list) < a:
	item = input()
	list.append(item)
for k in range(a - 1):
	if list[k] != list[k + 1]:
		cnt += 1
print(cnt + 1)


n = int(input())
l = list('12')
w = 0
for i in range(n):
	a = input()
	if a != l[-1]:
		w = w + 1
	l.append(a)
print(w)


g = 1
z = []
inp = int(input())
for x in range(inp):
	z.append(input())
for c in range(inp - 1):
	if z[c] == z[c + 1]:
		g += 0
	else:
		g += 1
print(g)


n = int(input())
temp = input()
n = n - 1
c = 1
while n:
	a = input()
	if temp[1] == a[0]:
		c += 1
	temp = a
	n -= 1
print(c)


x = int(input())
lis = []
count = 1
for i in range(x):
	y = input()
	lis.append(y)
for i in range(len(lis) - 1):
	a = lis[i]
	b = lis[i + 1]
	if a[1] == b[0]:
		count += 1
print(count)


n = int(input())
mag = input()
c = 1
if n > 1:
	for i in range(n - 1):
		nm = input()
		if mag != nm:
			c += 1
			mag = nm
	print(c)
else:
	print(1)


import os, sys, atexit
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n = int(input())
(ans, s) = (1, input())
for i in range(n - 1):
	s1 = input()
	if s1[0] == s[1]:
		ans -= -1
	s = s1
print(ans)


n = int(input())
b = ''
c = 0
for i in range(n):
	a = input()
	if a[1] == '0':
		b += a
	elif a[1] == '1':
		b += a
for j in range(1, len(b)):
	if b[j - 1] == b[j]:
		c += 1
print(c + 1)


n = int(input())
groups = 1
magnets = []
for _ in range(n):
	magnets.append(input())
for m in range(n - 1):
	if magnets[m][-1] == magnets[m + 1][0]:
		groups += 1
print(groups)


import sys
n = int(input())
firstMagnet = input()
magnets = []
magnets.append(firstMagnet)
magnet_chain = firstMagnet
while n - 1 > 0:
	magnet = input()
	lastMagnet = magnets[-1]
	if lastMagnet[-1] != magnet[0]:
		magnet_chain += magnet
	else:
		magnet_chain += ' ' + magnet
	magnets.append(magnet)
	n -= 1
print(max(len(magnet_chain.split()), 1))


n = int(input())
lt = [input() for i in range(n)]
lt1 = [i[:-1] for i in lt]
groups = 1
a = str(lt1[0])
for i in lt1:
	if str(i) != a:
		groups += 1
	a = str(i)
print(groups)


switch_counter = 0
n = int(input())
prev_s = input()
for i in range(n - 1):
	curr_s = input()
	if curr_s != prev_s:
		switch_counter += 1
	prev_s = curr_s
print(switch_counter + 1)


S = ''
cnt = 0
for i in range(int(input())):
	s = input()
	if len(S) == 0:
		S += s
		cnt += 1
	elif S[-1] != s[-1]:
		cnt += 1
		S += s
print(cnt)


n = int(input())
mag = []
for i in range(n):
	mag.append(input())
count = 0
if n == 1:
	print(1)
else:
	for i in range(n - 1):
		a = str(mag[i])
		b = str(mag[i + 1])
		if a[1] == b[0]:
			count += 1
	print(count + 1)


n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
count = 1
for i in range(1, len(l)):
	if l[i] != l[i - 1] and count == 0:
		count += 2
	elif l[i] != l[i - 1]:
		count += 1
print(count)


n = int(input())
num = input()
sum = 1
last = '1'
if num == '10':
	last = '0'
for i in range(1, n):
	num = input()
	if num[0] == last:
		sum += 1
		last = str(1 - int(last))
print(sum)


qnt = int(input())
anterior = input()
count = 1
for _ in range(qnt - 1):
	a = input()
	if a != anterior:
		count += 1
		anterior = a
print(count)


dig = int(input())
lis = []
group = 1
for i in range(dig):
	mag = input()
	lis.append(mag)
plis = ''.join(lis)
for x in range(dig * 2 - 1):
	if plis[x] == '0' and plis[x + 1] == '0' or (plis[x] == '1' and plis[x + 1] == '1'):
		group += 1
print(group)


k = int(input())
a = []
for i in range(k):
	x = int(input())
	a.append(x)
y = 0
for i in range(k - 1):
	if a[i] != a[i + 1]:
		y += 1
	else:
		y += 0
print(y + 1)


n = int(input())
c = 1
a = []
for j in range(n):
	s = input()
	a.append(s)
for i in range(len(a) - 1):
	if a[i] == '10' and a[i + 1] == '01' or (a[i] == '01' and a[i + 1] == '10'):
		c += 1
print(c)


def ty(s1, s2):
	if s1 == '01' and s2 == '10' or (s1 == '10' and s2 == '01'):
		return False
	return True

def mag(arr):
	ans = 1
	for i in range(1, len(arr)):
		curr = arr[i]
		if ty(arr[i - 1], curr):
			continue
		else:
			ans += 1
	return ans
arr = []
t = int(input())
for i in range(t):
	arr.append(input())
print(mag(arr))


def _344A(numbers):
	count = 0
	for index in range(1, len(numbers)):
		if numbers[index] != numbers[index - 1]:
			count += 1
	return count + 1
n = int(input())
numbers = []
for index in range(n):
	numbers.append(input())
print(_344A(numbers))


from collections import defaultdict
arr = []
n = int(input())
for i in range(n):
	s = str(input())
	arr.append(s)
cnt = 1
for i in range(1, len(arr)):
	if arr[i][0] == arr[i - 1][1]:
		cnt += 1
print(cnt)


number_of_magnets = int(input())
island = 1
magnets = []
for magnet in range(number_of_magnets):
	magnets.append(input())
islands = 1
for magnet_pair in list(zip(magnets[1:], magnets)):
	if magnet_pair[0] != magnet_pair[1]:
		islands += 1
	continue
print(islands)


n = int(input())
cnt = 1
cur = input()
for _ in range(n - 1):
	s = input()
	if s != cur:
		cnt += 1
		cur = s
print(cnt)


n = int(input())
z = 0
a = ''
for i in range(n):
	d = str(input())
	if a != d:
		z = z + 1
		a = d
	else:
		z = z
print(z)


n = int(input())
c = 0
li = []
for i in range(n):
	x = int(input())
	li.append(x)
if len(li) > 1:
	for i in range(len(li) - 1):
		if li[i] != li[i + 1]:
			c += 1
	print(c + 1)
else:
	print('1')


n = int(input())
pre = str(input())
ct = 1
for i in range(n - 1):
	s = str(input())
	if pre != s:
		ct += 1
	pre = s
print(ct)


import sys

def magnets():
	datain = []
	count = 1
	for i in range(int(input())):
		datain.append(int(input()))
	for i in range(len(datain) - 1):
		if datain[i] != datain[i + 1]:
			count += 1
	print(count)
magnets()


l = []
n = int(input())
for i in range(n):
	l.append(input())
if n == 1:
	print(1)
	quit()
c = 1
for i in range(0, len(l) - 1):
	if l[i][-1] == l[i + 1][-2]:
		c += 1
print(c)


n = int(input())
args = []
for _ in range(n):
	args.append(input())
l = 1
i = 1
while i < n:
	if args[i - 1] != args[i]:
		l += 1
	i += 1
print(l)


n = int(input())
num = list((input() for i in range(n)))
sum = 0
for i in range(1, len(num)):
	if num[i - 1] != num[i]:
		sum = sum + 1
print(sum + 1)


num = int(input())
if num == 1:
	print(1)
else:
	string = ''
	for x in range(num):
		string += input()
	print(1 + string.count('00') + string.count('11'))


N = int(input())
count = 1
ARR = [input() for i in range(N)]
l = len(ARR) - 1
for i in range(l):
	if ARR[i] != ARR[i + 1]:
		count += 1
print(count)


n = int(input())
order = list()
c = 0
for i in range(1, n + 1, 1):
	mag = int(input())
	order.append(mag)
compare = order[0]
for i in order:
	if i != compare:
		compare = i
		c += 1
c += 1
print(c)


n = int(input())
if n >= 1 and n <= 100000:
	c = 1
	s = input()
	for i in range(n - 1):
		x = input()
		if s == x:
			c = c + 0
		else:
			c = c + 1
			s = x
	print(c)


n = int(input())
pre = None
counter = 0
for i in range(n):
	s = input()
	if pre != s:
		counter += 1
	pre = s
print(counter)


first_num = input()
first_num = int(first_num)
string_holder = ''
for i in range(first_num):
	string_holder += input()
one_count = string_holder.count('11')
zero_count = string_holder.count('00')
total_val = one_count + zero_count + 1
print(total_val)


cases = int(input())
lst = []
count = 1
for i in range(cases):
	lst.append(int(input()))
for i in range(len(lst) - 1):
	if lst[i] != lst[i + 1]:
		count += 1
print(count)


r = input
c = p = 0
for i in ' ' * int(r()):
	s = r()
	c += s != p
	p = s
print(c)


a = int(input())
c = ''
for i in range(a):
	b = input()
	c = c + b
c = c.replace('00', '0 0')
c = c.replace('11', '1 1')
print(c.count(' ') + 1)


def function1(n, s):
	k = 1
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			k += 1
	return k

def main():
	n = int(input())
	s = [int(input()) for i in range(n)]
	print(function1(n, s))
main()


I = lambda : int(input())
Sum = 0
pre = 0
n = I()
for i in range(n):
	IN = I()
	if IN != pre:
		Sum += 1
	pre = IN
print(Sum)


noOfInputs = int(input())
all_magnets = [int(input()) for x in range(noOfInputs)]
previous_magnet = all_magnets[0]
groups = 1
for this_magnet in all_magnets:
	if this_magnet == previous_magnet:
		continue
	else:
		groups += 1
	previous_magnet = this_magnet
print(groups)


x = int(input())
s = []
k = 1
for i in range(x):
	s.append(input())
for i in range(x):
	if i == x - 1:
		continue
	if s[i] != s[i + 1]:
		k = k + 1
print(k)


n = input()
n = int(n)
magnets = []
blocks = 1
for i in range(n):
	magnets.append(input())
for i in range(n):
	if i != n - 1:
		tmp = magnets[i]
		tmp2 = magnets[i + 1]
		if tmp[1] == tmp2[0]:
			blocks += 1
print(blocks)


x = int(input())
if x == 1:
	print(1)
else:
	groups = 1
	m = []
	for _ in range(x):
		m.append(input())
	j = 1
	for j in range(1, len(m)):
		if m[j][1] == m[j - 1][0]:
			groups += 1
			j += 1
	print(groups)


import re
n = int(input())
arr = []
for i in range(n):
	string = str(input())
	arr.append(string)
string2 = ''
for i in arr:
	string2 += i
x = re.findall('00', string2)
y = re.findall('11', string2)
print(len(x) + len(y) + 1)


r = [input() for _ in range(int(input()))]
print(1 + sum((a != b for (a, b) in zip(r, r[1:]))))


a = int(input())
count = 0
c = -1
for i in range(a):
	s = int(input())
	k = s % 10
	if k == c:
		count += 1
	c = s // 10
print(count + 1)


def solve(magnets):
	k = 0
	last = magnets[0]
	for m in magnets:
		if last != m:
			k += 1
			last = m
	return k + 1
n = int(input())
magnets = []
for i in range(n):
	magnets.append(input())
print(solve(magnets))


def mCheckInputs(identifier, inputList):
	if identifier == 'int':
		if inputList[0].isdigit() and 1 <= int(inputList[0]) <= 100000:
			pass
		else:
			exit(1)
	else:
		exit(1)

def mHandleInputs(inputList):
	n = input()
	inputList.append(n)
	mCheckInputs('int', inputList)
	userInputList = []
	for i in range(int(n)):
		userInputList.append(input())
	inputList[0] = userInputList

def mDoWork(inputList, outputList):
	result = 1
	n = inputList.__len__()
	comparisonItem = 0
	for item in inputList[0]:
		if comparisonItem == 0:
			comparisonItem = item
		elif item.isdigit() and item.__len__() == 2 and (item.count('0') == 1) and (item.count('1') == 1):
			if item != comparisonItem:
				result += 1
				comparisonItem = item
			else:
				continue
		else:
			exit(1)
	outputList.append(result)

def mFormatResult(outputList):
	print(outputList[0])

def main():
	inputList = []
	mHandleInputs(inputList)
	outputList = []
	mDoWork(inputList, outputList)
	mFormatResult(outputList)
main()


n = int(input())
lista = []
for i in range(n):
	troco = input()
	lista.append(troco)
count = 1
for i in range(n):
	if i == n - 1:
		break
	if lista[i] == '01' and lista[i + 1] == '10':
		count += 1
	if lista[i] == '10' and lista[i + 1] == '01':
		count += 1
	else:
		pass
print(count)


n = int(input())
if 1 <= n <= 100000:
	st = []
	while True:
		if len(st) < n:
			k = input()
			st.append(k)
		else:
			break
	count = 1
	j = 0
	while j <= len(st) - 2:
		if st[j] == '10' and st[j + 1] == '10' or (st[j] == '01' and st[j + 1] == '01'):
			j += 1
		else:
			count += 1
			j += 1
	print(count)


magnet_number = int(input())
lst = []
for i in range(magnet_number):
	sign = input()
	lst.append(sign)
hitung = 0
for i in range(len(lst)):
	if i < len(lst) - 1:
		if lst[i] == lst[i + 1]:
			pass
		else:
			a = 0
			while a < 1:
				hitung += 1
				a += 1
	elif lst[i] == lst[i - 1]:
		hitung += 1
	else:
		hitung += 1
print(hitung)


n = int(input())
list1 = []
num = 1
for i in range(n):
	a = input()
	list1.append(a)
list2 = [int(x) for x in list1]
for i in range(len(list2) - 1):
	if list2[i] != list2[i + 1]:
		num += 1
print(num)


x = int(input())
y = input()

def magnet(x, y):
	n = 1
	if x == 1:
		return 1
	for i in range(x - 1):
		k = y[1]
		y = input()
		if y[0] == k:
			n += 1
	return n
print(magnet(x, y))


t = int(input())
s = ''
while t:
	s += input()
	t -= 1
one = s.count('11')
zero = s.count('00')
print(one + zero + 1)


x = int(input())
m = []
t = 0
jvab = 0
for i in range(x):
	m.append(int(input()))
	if i > 0 and m[i] != t:
		jvab += 1
	t = m[i]
print(jvab + 1)


n = int(input())
magnets = []
for i in range(n):
	tmp = int(input())
	magnets.append(tmp)
ans = 0
for i in range(len(magnets) - 1):
	if magnets[i] == magnets[i + 1]:
		pass
	else:
		ans += 1
print(ans + 1)


(c, d, e) = (0, '0', 0)
for case in ' ' * int(input()):
	c = input()
	if c != d:
		e += 1
		d = c
print(e)


total = 1
l = []
for i in range(int(input())):
	a = int(input())
	if len(l) == 0:
		l.append(a)
		continue
	if l[0] != a:
		l.remove(l[0])
		l.append(a)
		total += 1
print(total)


n = int(input())
j = 1
mag = ''
while n != 0:
	m = input()
	mag += m
	n -= 1
for i in range(len(mag) - 1):
	if mag[i] == mag[i + 1]:
		j += 1
print(j)


n = int(input())
now = input()
count = 1
for i in range(n - 1):
	nex = input()
	if nex != now:
		count += 1
		now = nex
print(count)


first_magnet = ''
counter = 0
for x in range(int(input())):
	second_magnet = str(input())
	if first_magnet != second_magnet:
		counter += 1
	first_magnet = second_magnet
print(counter)


n = int(input())
arr = []
i = 0
while i < n:
	arr.append(input())
	i += 1
group = 1
j = 0
while j < len(arr) - 1:
	if arr[j] != arr[j + 1]:
		group += 1
	j += 1
print(group)


num = int(input())
c = 0
arr = []
while c < num:
	arr.append(int(input()))
	c += 1
sum = 1
temp = arr[0]
for i in range(1, len(arr)):
	if arr[i] != temp:
		sum += 1
	temp = arr[i]
print(sum)


n = int(input(''))
a = []
for i in range(n):
	s = input('')
	a.append(s)
if len(a) == 1:
	print('1')
else:
	counter = 0
	for i in range(1, len(a)):
		if a[i] != a[i - 1]:
			counter += 1
	print(counter + 1)


n_magnets = int(input())
magnets = []
for _ in range(n_magnets):
	magnets.append(input())

def split_groups(arr):
	res = arr[0:1]
	last_elem = arr[0]
	for elem in arr[1:]:
		if elem == last_elem:
			res.append(elem)
		else:
			yield res
			res = [elem]
		last_elem = elem
	if len(res) != 0:
		yield res
print(len(list(split_groups(magnets))))


k = int(input())
count = 0
position = []
while count < k:
	n = input()
	position.append(n)
	count += 1
group = 0
for x in range(0, len(position) - 1):
	if position[x] == '10' and position[x + 1] == '01':
		group += 1
	elif position[x] == '01' and position[x + 1] == '10':
		group += 1
	else:
		pass
print(group + 1)


n = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
if len(l) == 1:
	o = 1
elif len(l) > 1:
	o = 1
	b = 0
	while b <= len(l) - 2:
		if l[b] == 1 and l[b + 1] == 1 or (l[b] == 10 and l[b + 1] == 10):
			b += 1
		else:
			o += 1
			b += 1
print(o)


x = int(input())
y = input()
group = 1
for a in range(0, x - 1):
	n = input()
	if n != y:
		group += 1
	y = n
print(group)


n = int(input())
count = 1
s1 = input()
while n - 1 > 0:
	s = input()
	if s != s1:
		count += 1
		s1 = s1[::-1]
	n -= 1
print(count)


s = 0
prev = ''
for i in range(int(input())):
	kk = input()
	if kk != prev:
		s += 1
		prev = kk
print(s)


a = int(input())
m = 0
ostr = 0
for i in range(a):
	b = int(input())
	if b != m:
		ostr += 1
	m = b
print(ostr)


n = int(input())
t = []
k = 1
for i in range(n):
	t.append(int(input()))
for i in range(1, n):
	if t[i - 1] != t[i]:
		k += 1
print(k)


n = int(input())
count = 1
anterior = None
for _ in range(n):
	atual = input()
	if anterior == atual[0]:
		count += 1
	anterior = atual[1]
print(count if count != 0 else 1)


n = int(input()) - 1
plus = input() == '10'
s = 1
for i in range(n):
	if (input() == '10') != plus:
		plus = not plus
		s += 1
print(s)


n = int(input())
arr = ['a7a'] * n
i = int(0)
for i in range(0, n):
	arr[i] = input()
g_c = int(1)
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		g_c = g_c + 1
print(g_c)


a = int(input())
a1 = input()
k = 1
for i in range(a - 1):
	l = input()
	if a1 != l:
		a1 = l
		k += 1
print(k)


n = int(input())
z = 0
x1 = 0
for i in range(n):
	x = int(input())
	if x - x1 != 0:
		z = z + 1
	x1 = x
print(z)


n = int(input())
x = []
group = 1
for i in range(n):
	y = input()
	x.append(list(y[:]))
for i in range(n - 1):
	if x[i][1] == x[i + 1][0]:
		group += 1
	else:
		pass
print(group)


a = int(input())
c = input()
d = 1
while a > 1:
	b = input()
	if b != c:
		d += 1
		c = b
	a -= 1
print(d)


t = int(input())
prev = input()
counter = 0
for _ in range(t - 1):
	cur = input()
	if cur != prev:
		counter += 1
	prev = cur
print(counter + 1)


from sys import stdin
_ = stdin.readline()
groups = 1
flip_flop = 0
f = int(stdin.readline())
if f == 1:
	flip_flop = 0
else:
	flip_flop = 1
for line in stdin.readlines():
	if int(line) == 1:
		if flip_flop == 0:
			continue
		else:
			flip_flop = 0
			groups += 1
	elif flip_flop == 0:
		flip_flop = 1
		groups += 1
	else:
		continue
print(groups)


n = int(input()) - 1
s = input()
a = 1
while n:
	n -= 1
	x = input()
	if x != s:
		a += 1
	s = x
print(a)


mgnts = int(input())
lst = []
for i in range(mgnts):
	mgn = input()
	lst.append(mgn)
grps = 1
for j in range(1, mgnts):
	if lst[j] != lst[j - 1]:
		grps += 1
print(grps)


from sys import stdin, stdout
n = int(input())
(p, q) = ('10', '01')
l = 1
t = stdin.readline()
for i in range(n - 1):
	k = stdin.readline()
	if k == t:
		continue
	else:
		t = k
		l += 1
print(l)


num_magnets = int(input())
groups = 1
count = 0
all_magnets = []
for magnets in range(num_magnets):
	new_magnet = list(input())
	all_magnets.append(new_magnet)
for i in range(1, len(all_magnets)):
	if all_magnets[i][0] == all_magnets[i - 1][1]:
		groups += 1
print(groups)


n = int(input())
ng = 1
u = int(input())
x = u % 10
y = u // 10
for i in range(n - 1):
	l = int(input())
	k = l % 10
	m = l // 10
	if m != x:
		x = k
	else:
		ng += 1
		x = k
print(ng)


n = int(input())
groups = 1
magnet_prev = input()
magnet_after = ''
for i in range(n - 1):
	magnet_after = input()
	if magnet_prev != magnet_after:
		groups += 1
	magnet_prev = magnet_after
print(groups)


n = int(input())
a = ''
s = 0
for i in range(1, n + 1):
	q = a
	a = input()
	if i == 1:
		continue
	elif q != a:
		s += 1
	else:
		continue
print(s + 1)


temp = 0
count = 1
for i in range(int(input())):
	phase = input()
	if temp == 0:
		temp = phase
	if temp != phase:
		count += 1
		temp = phase
print(count)


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
n = iinp()
grupos = 1
imanes = [inp()]
for i in range(1, n):
	imanes.append(inp())
	if imanes[-2][-1] == imanes[-1][0]:
		grupos += 1
print(grupos)


n = int(input())
magnes1 = '0'
grupy = 0
for i in range(n):
	magnes2 = input()
	if magnes1 != magnes2:
		grupy += 1
	magnes1 = magnes2
print(grupy)


n = int(input(''))
ans = []
l = []
c = 0
b = 0
for _ in range(n):
	x = input('')
	ans.append(x)
for i in range(len(ans)):
	a = ans[i]
	if a != b:
		c += 1
		b = a
print(c)


n = int(input())
c = 0
curr = ''
for i in range(n):
	p = input()
	if i == 0:
		c += 1
		curr = p
	elif p == curr:
		continue
	else:
		c += 1
		curr = p
print(c)


import sys
from random import choice, randint
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().strip().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().strip().split()]

def LS():
	return sys.stdin.readline().strip().split()

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

def F():
	return float(sys.stdin.readline().strip())

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

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))
inp = sys.stdin.readline
out = sys.stdout.write

def main():
	n = I()
	c = 0
	l = []
	s = S()
	l.append(s)
	for i in range(n - 1):
		s = S()
		if s != l[-1]:
			c += 1
		l.append(s)
	pf(c + 1)
main()


n = int(input())
c = 1
s = []
for i in range(n):
	s.append(input())
y = s[0][1]
for x in range(1, n):
	if s[x][0] == y:
		c += 1
		y = s[x][1]
print(c)


magnet = 1
x = int(input())
y = int(input())
for i in range(1, x):
	z = int(input())
	if y != z:
		magnet += 1
		y = z
print(magnet)


n = int(input())
alist = []
for x in range(int(n)):
	o = input()
	alist.append(o)
grp = 1
for b in range(len(alist) - 1):
	if alist[b] != alist[b + 1]:
		grp += 1
print(grp)


n = int(input())
count = 0
t = []
for i in range(n):
	s = input()
	t.append(s)
for j in range(len(t) - 1):
	if t[j] != t[j + 1]:
		count += 1
print(count + 1)


t = 0
m = [input() for _ in range(int(input()))]
for x in range(len(m) - 1):
	if m[x] != m[x + 1]:
		t += 1
print(t + 1)


joop = int(input())
jessie = str(input())
lmao = 1
for i in range(joop - 1):
	james = str(input())
	if jessie != james:
		lmao += 1
	jessie = james
print(lmao)


cek = ''
hasil = 0
for i in range(int(input())):
	n = input()
	if cek != n:
		hasil += 1
		cek = n
print(hasil)


n = int(input())
l = 0
f = 0
co = 0
for i in range(n):
	s = input()
	ls = list(s)
	if i > 0:
		if ls[0] == l:
			co += 1
	f = ls[0]
	l = ls[1]
print(co + 1)


n = int(input())
ans = 1
temp = input()
for i in range(n - 1):
	now = input()
	if now != temp:
		ans += 1
		temp = now
print(ans)


number_of_magnets = int(input())
nb_of_groups = 0
last_magnet = None
for i in range(number_of_magnets):
	current_magnet = int(input())
	if current_magnet != last_magnet:
		nb_of_groups += 1
	last_magnet = current_magnet
print(nb_of_groups)


n = int(input())
groups = 1
prev = (0, 1) if input() == '01' else (1, 0)
for _ in range(1, n):
	curr = (0, 1) if input() == '01' else (1, 0)
	if curr != prev:
		groups += 1
		prev = curr
print(groups)


from itertools import groupby
print(len(list(groupby([input() for i in range(int(input()))]))))


def algo(inp):
	magnets = []
	group = 1
	for i in range(inp):
		magnet = input()
		magnets.append(magnet)
		if str(magnets[i])[0] == str(magnets[i - 1])[1]:
			group += 1
	print(group)
inp = int(input())
algo(inp)


n = int(input())
m = 'aa'
dem = 0
for i in range(n):
	l = m
	m = input()
	if l != m:
		dem += 1
print(dem)


n = int(input())
x = n * [0]
for i in range(n):
	x[i] = input()
res = 1
for i in range(0, n - 1):
	if x[i] != x[i + 1]:
		res += 1
print(res)


n = int(input())
li = []
c = 0
for i in range(n):
	x = [li.append(a) for a in input().split()]
for i in range(n - 1):
	if li[i] != li[i + 1]:
		c += 1
print(c + 1)


n = int(input())
count = 0
prev = None
for i in range(n):
	fat = input()
	if fat != prev:
		count += 1
	prev = fat
print(count)


n = int(input())
cnt = 1
nums = []
for i in range(n):
	x = int(input())
	nums.append(x)
for j in range(len(nums) - 1):
	if nums[j] == nums[j + 1]:
		cnt += 0
	else:
		cnt += 1
print(cnt)


n = int(input())
if n == 1:
	x = input()
	print(1)
elif n == 2:
	x = input()
	s = input()
	if x == s:
		print(1)
	else:
		print(2)
else:
	y = input()
	a = y[0]
	c = 0
	s = ''
	f = True
	z = True
	while n - 1 > 0:
		x = input()
		if y != x and z:
			c += 1
		if x == s:
			f = False
		elif a == x[0] and f:
			c += 1
			s = x
			f = False
		elif not a == x[0]:
			a = x[0]
			c += 1
			s = x
			f = True
		z = False
		n -= 1
	print(c)


import sys

def input():
	return sys.stdin.readline().strip()
n = int(input())
count = 0
s = ''
for i in range(n):
	s += input()
for i in range(2, 2 * n, 2):
	if s[i] == s[i - 1]:
		count += 1
print(count + 1)


il = []
n = int(input())
for i in range(n):
	arr = input()
	il.append(arr)
prev = None
count = 1
for i in il:
	if prev == None:
		prev = i
	elif i == prev:
		continue
	else:
		count += 1
		prev = i
print(count)


from sys import stdin
t = int(stdin.readline())
l = int(stdin.readline())
g = 0
for i in range(t - 1):
	n = int(stdin.readline())
	if not n == l:
		g += 1
	l = n + 0
g += 1
print(g)


import sys
c = 0
a = '11'
for i in ' ' * int(input()):
	group = sys.stdin.readline()
	if a != group:
		c += 1
	a = group
print(c)


n = int(input())
haha = []
count = 0
for _ in range(n):
	haha.append(input())
result = ''.join(haha)
for i in range(len(result) - 1):
	if result[i] == result[i + 1]:
		count += 1
print(count + 1)


n = int(input())
l = []
for _ in range(n):
	t = int(input())
	l.append(t)
count = 1
for i in range(n - 1):
	if l[i] != l[i + 1]:
		count += 1
print(count)


magnets = []
result = 1
n = int(input())
for i in range(n):
	magnets.append(input())
for i in range(n - 1):
	if magnets[i] == magnets[i + 1]:
		continue
	else:
		result += 1
print(result)


arr = []
count = 0
p = ''
for i in range(int(input())):
	x = input()
	if x != p:
		count += 1
	p = x
print(count)


n = int(input())
group = 1
for i in range(n):
	s = input()
	if i == 0:
		p = s
	elif s[0] != p[1]:
		p = s
		continue
	else:
		group += 1
		p = s
print(group)


n = int(input())
t = []
count = 1
for i in range(n):
	m = int(input())
	t.append(m)
k = t[0]
for i in range(1, n):
	if k != t[i]:
		count = count + 1
	k = t[i]
print(count)


n = int(input())
cnt = 1
pre = input()
for i in range(n - 1):
	now = input()
	if int(pre) + int(now) == 11:
		cnt += 1
	pre = now
print(cnt)


n = int(input())
su = 1
for i in range(n):
	s = input()
	if i == 0:
		n = s
		continue
	if s == n:
		n = s
		continue
	else:
		su += 1
	n = s
print(su)


n = int(input())
magn = []
groups = 1
for i in range(n):
	magn.append(int(input()))
tmp = magn[0]
for i in magn:
	if i != tmp:
		groups = groups + 1
	tmp = i
print(groups)


n = int(input(''))
inp = list()
count = 0
curr = 0
prev = 0
for i in range(0, n):
	tmp = int(input(''))
	curr = tmp
	if curr != prev:
		count += 1
	prev = curr
print(count)


n = int(input())
o = 1
r = []
for i in range(n):
	a = int(input())
	r.append(a)
	while len(r) - 1 > 0:
		if r[0] != r[1]:
			o = o + 1
		r.pop(0)
print(o)


n = int(input())
f = []
count = 1
for i in range(n):
	x = input()
	f.append(x)
for i in range(n - 1):
	if f[i] != f[i + 1]:
		count = count + 1
	else:
		count = count + 0
print(count)


def solve(n):
	actual = ''
	anterior = ''
	grupos = 0
	for i in range(n):
		actual = input()
		if actual != anterior:
			grupos += 1
		anterior = actual
	return grupos
n = input()
print(solve(int(n)))


n = int(input())
check1 = input()
sen = 1
for i in range(n - 1):
	check2 = input()
	if check1 != check2:
		sen += 1
	check1 = check2
print(sen)


n = int(input())
a = None
b = None
cnt = 1
for _ in range(n):
	a = input()
	if b != None:
		if b != a:
			cnt += 1
			b = a
	else:
		b = a
print(cnt)


from array import *
x = int(input())
vals = array('L', [])
groups = 1
for i in range(x):
	y = int(input(''))
	vals.append(y)
	if i == 0:
		continue
	elif y != vals[i - 1]:
		groups += 1
	else:
		continue
print(groups)


n = int(input())
t = '11'
count = 0
for _ in range(n):
	a = input()
	if a != t:
		t = a
		count += 1
print(count)


magnet = int(input())
string1 = ''
for i in range(magnet):
	string1 += input().strip('\n\r')
print(string1.count('00') + string1.count('11') + 1)


n = int(input())
pre = input()
group = 1
for i in range(n - 1):
	tmp = input()
	if tmp != pre:
		group = group + 1
		pre = tmp
print(str(group))


pre = 0
count = 0
for i in range(int(input())):
	a = int(input())
	if pre != a:
		count += 1
		pre = a
print(count)


len = int(input())
i = 0
t = []
while i < len:
	t.append(input())
	i = i + 1
count = 0
prev = 0
for x in t:
	if prev == 0:
		prev = x
	elif x != prev:
		prev = x
		count = count + 1
	else:
		prev = x
print(count + 1)


import sys

def getInput():
	return sys.stdin.readline()[:-1]
magnets = int(getInput())
currMag = getInput()
groups = 1
for x in range(magnets - 1):
	nextMag = getInput()
	groups += 0 if nextMag == currMag else 1
	currMag = nextMag
print(groups)


n = int(input())
k = 1
sp = [int(input()) for i in range(n)]
if n == 1:
	print(1)
else:
	for i in range(1, n):
		if sp[i - 1] % 10 == sp[i] // 10:
			k += 1
	print(k)


number0 = int(input())
list0 = []
counter = 1
for i in range(number0):
	s = input()
	list0.append(s)
for i in range(number0 - 1):
	if list0[i] != list0[i + 1]:
		counter += 1
print(counter)


t = int(input())
c = []
for i in range(t):
	c.append(int(input()))
d = 0
for i in range(t - 1):
	if c[i] != c[i + 1]:
		d += 1
print(d + 1)


n = int(input())
str = input()
LAST = str[1]
S = 1
n -= 1
while n > 0:
	str = input()
	if str[0] == LAST:
		S += 1
		LAST = str[1]
	n -= 1
print(S)


n = int(input())
jieguo = 1
l = []
for i in range(n):
	a = str(input())
	l.append(a)
for i in range(n - 1):
	if l[i] != l[i + 1]:
		jieguo += 1
print(jieguo)


n = int(input())
space = 0
lst = []
for i in range(n):
	a = int(input())
	lst.append(a)
first = lst[0]
for i in range(n - 1):
	if lst[i] != lst[i + 1]:
		space += 1
print(space + 1)


n = int(input())
prev_in = int(input())
count = 1
for i in range(n - 1):
	res = int(input())
	if prev_in != res:
		count += 1
		prev_in = res
print(count)


n = int(input())
grupos = 0
atual = ''
for i in range(n):
	mag = input()
	if mag != atual:
		grupos += 1
		atual = mag
print(grupos)


n = int(input())
s = []
i = 0
while i < n:
	h = int(input())
	s.append(h)
	i += 1
l = 0
k = 0
for r in range(len(s) - 1):
	if s[l] != s[l + 1]:
		k += 1
	l += 1
print(k + 1)


a = int(input())
before = ''
hasil = 0
for i in range(a):
	nxt = input()
	if nxt != before:
		hasil += 1
		before = nxt
print(hasil)


n = int(input())
q = []
for j in range(n):
	i = int(input())
	q.append(i)
a = 0
b = 0
k = 0
while a <= len(q) - 2:
	if q[a] == q[a + 1]:
		b = b + 1
		a = a + 1
	else:
		k = k + 1
		a = a + 1
print(k + 1)


n = int(input())
c = 0
x = ''
s = ''
while n > 0:
	n = n - 1
	s = input()
	if x != s:
		c = c + 1
	x = s
print(c)


n = int(input())
ps = '0'
ans = 0
for x in range(n):
	s = input()
	if s != ps:
		ans += 1
	ps = s
print(ans)


n = int(input())
str1 = input()
groups = 1
while n - 1 > 0:
	str2 = input()
	if str1 == str2:
		n -= 1
		str1 = str2
	else:
		groups += 1
		n -= 1
		str1 = str2
print(groups)


n = int(input())
count = 0
count1 = 0
ar = ''
ar1 = []
for i in range(n):
	m = input()
	ar = ar + m
for i in range(1, len(ar)):
	if ar[i] == ar[i - 1]:
		count = count + 1
print(count + 1)


n = int(input())
str = input()
x = 1
for i in range(n - 1):
	loop_str = input()
	if str[1] == loop_str[0]:
		x += 1
	str = loop_str
print(x)


n = int(input())
i = 0
li = list()
while i < n:
	li.append(input())
	i = i + 1
count = 1
i = 0
while i < n - 1:
	if li[i] != li[i + 1]:
		count = count + 1
	i = i + 1
print(count)


x = int(input())
w = 1
for i in range(0, x):
	y = int(input())
	if i == 0:
		first = y
	elif y != first:
		first = y
		w += 1
print(w)


same_pole = ''
grp = 0
for _ in range(int(input())):
	mag = input()
	if mag == same_pole:
		continue
	else:
		grp = grp + 1
		same_pole = mag
print(grp)


n = int(input())
c = []
s = 1
for i in range(n):
	c.append(list(map(int, input().split())))
for j in range(len(c) - 1):
	if c[j] != c[j + 1]:
		s += 1
print(s)


nOfMagnets = int(input())
i = 0
ans = 0
pre = ''
while i < nOfMagnets:
	cur = input()
	if cur != pre:
		ans += 1
		pre = cur
	i += 1
print(ans)


ls = []
counter = 1
n = int(input())
for _ in range(n):
	ls.append(int(input()))
for i in range(n - 1):
	if ls[i] != ls[i + 1]:
		counter += 1
print(counter)


n = int(input())
c = 1
sp = input()
for i in range(n - 1):
	sc = input()
	if sc[0] == sp[-1]:
		c += 1
	sp = sc
print(c)


def magnets():
	n = int(input())
	l = []
	s = ''
	count = 1
	for i in range(n):
		l.append(input())
		if i == 0:
			pass
		elif l[i] == l[i - 1]:
			pass
		elif l[i] != l[i - 1]:
			count += 1
	return count
print(magnets())


n = int(input())
sum = 0
magnet = 0
for i in range(n):
	magneti = input()
	if magneti != magnet:
		sum += 1
		magnet = magneti
print(sum)


lis = []
hm = int(input())
tot = 1
for i in range(hm):
	lis.append(input())
for i in range(hm):
	try:
		if lis[i] != lis[i + 1]:
			tot += 1
	except IndexError:
		break
print(tot)


import math
import re
a = int(input())
count = 0
last = input()
for i in range(a - 1):
	curr = input()
	if curr[0] == last[1]:
		count += 1
	last = curr
print(count + 1)


l = []
count = 1
for _ in range(int(input())):
	l.append(input())
for i in range(1, len(l)):
	if l[i - 1] != l[i]:
		count += 1
print(count)


n = int(input())
count = 0
a = input()
if a == '10':
	p = 1
else:
	p = 0
for i in range(n - 1):
	s = input()
	if p == 1:
		if s == '10':
			continue
		else:
			count += 1
			p = 0
	elif s == '10':
		count += 1
		p = 1
	else:
		continue
print(count + 1)


d = [input() for i in range(int(input()))]
a = 1
cur = d[0]
for m in d[1:]:
	if m != cur:
		cur = m
		a += 1
print(a)


from sys import stdin, stdout

def sin():
	return stdin.readline().rstrip()

def listInput():
	return list(map(int, sin().split()))

def printBS(li):
	if not li:
		return
	for i in range(len(li) - 1):
		stdout.write('%d ' % li[i])
	stdout.write('%d\n' % li[-1])
n = int(sin())
li = []
for i in range(n):
	li.append(sin())
cnt = 0
prev = ''
for i in li:
	if i == prev:
		continue
	else:
		cnt += 1
		prev = i
print(cnt)


y = ''
for i in range(int(input())):
	y += input()
print(y.count('1001') + y.count('0110') + 1)


n = int(input())
count = 0
flag_init = True
pre_mag = ''
while n > 0:
	n -= 1
	mag = input()
	if flag_init:
		count = 1
		pre_mag = mag
		flag_init = False
	if mag == pre_mag:
		continue
	count += 1
	pre_mag = mag
print(count)


n = int(input())
g = 1
p = input()
for i in range(n - 1):
	m = input()
	if m != p:
		g += 1
	p = m
print(g)


n = int(input())
groups = 1
curr = input()
for _ in range(n - 1):
	new = input()
	if curr[-1] == new[0]:
		groups += 1
	curr = new
print(groups)


from sys import stdin
n = int(stdin.readline())
counter = 0
previous = '00'
for w in range(n):
	a = stdin.readline()
	if previous != a:
		counter += 1
		previous = a
print(counter)


n = int(input())
i = 1
b = []
for _ in range(n):
	a = input()
	b.append(a)
for j in range(n - 1):
	if b[j][-1] == b[j + 1][0]:
		i += 1
print(i)


n = int(input())
lst = []
count = 1
for i in range(n):
	mag = int(input())
	lst.append(mag)
for j in range(n - 1):
	if lst[j] != lst[j + 1]:
		count += 1
print(count)


n = int(input())
s = []
g = 1
for i in range(0, n):
	s.append(input())
	if s[i] != s[i - 1] and len(s) > 1:
		g += 1
print(g)


n = int(input())
st = input()
gp = 0
lst = []
lst.append(st)
for i in range(1, n):
	st = input()
	if st == lst[gp]:
		pass
	else:
		gp += 1
		lst.append(st)
print(gp + 1)


n = int(input())
alist = []
num = 1
for i in range(n):
	a = input()
	alist.append(a)
for i in range(n - 1):
	if alist[i + 1] != alist[i]:
		num += 1
print(num)


a = int(input())
b = 0
arr = []
for i in range(a):
	ar = int(input())
	arr.append(ar)
for i in range(a - 1):
	if arr[i] != arr[i + 1]:
		b += 1
print(b + 1)


n = int(input())
ar = []
c = 0
for _ in range(n):
	k = input()
	ar.append(k)
fi = ar[0]
m = 0
for i in range(m + 1, n):
	if fi != ar[i]:
		m = ar.index(ar[i])
		fi = ar[i]
		c = c + 1
print(c + 1)


def noGroup(n):
	z = None
	noOfGroups = 0
	for i in range(0, n):
		x = int(input())
		if x is not z:
			z = x
			noOfGroups += 1
	return noOfGroups
n = int(input())
print(noGroup(n))


n = int(input())
c = 0
previous = ''
for i in range(n):
	m = input()
	if previous == '':
		previous = m
		c += 1
	elif m == previous:
		continue
	elif m != previous:
		previous = m
		c += 1
print(c)


from sys import stdin
(a, tot) = ('', 0)
for n in range(int(stdin.readline())):
	b = stdin.readline()
	if a != b:
		a = b
		tot += 1
print(tot)


n = int(input())
initial = int(input())
g = 1
for i in range(n - 1):
	p = int(input())
	if p == initial:
		pass
	else:
		g += 1
		initial = p
print(g)


a = int(input())
r = 0
z = ''
for i in range(a):
	k = str(input())
	if k != z:
		r += 1
	z = k
print(r)


a = int(input(''))
datalist = []
j = 0
count = 0
for i in range(a):
	a = input('')
	if j == 1:
		if b[1] == a[0]:
			count = count + 1
	j = 1
	b = a
print(count + 1)


n = input
k = p = 0
for i in ' ' * int(n()):
	s = n()
	k += s != p
	p = s
print(k)


from sys import stdin
input = stdin.readline

def magnet(n, t=1):
	a = [input().strip() for _ in range(n)]
	for i in range(1, n):
		if a[i] != a[i - 1]:
			t += 1
	return t
print(magnet(int(input())))


n = int(input())
if n == 1:
	print(1)
	raise SystemExit
x = input()
s = 1
for i in range(2, n + 1):
	y = input()
	if x[1] == y[0]:
		s = s + 1
	x = y
print(s)


c = m = 0
l = []
n = int(input())
for i in range(0, n):
	m = str(input())
	l.append(m)
for i in range(1, n):
	if l[i] != l[i - 1]:
		c += 1
	else:
		continue
print(c + 1)


t = eval(input())
magnets = list()
count = 1
for i in range(t):
	magnets.append(input())
for j in range(t - 1):
	if magnets[j] != magnets[j + 1]:
		count += 1
print(count)


x = int(input())
p = []
j = 0
c = 0
for n in range(0, x):
	p.append(input())
for i in range(0, x):
	if x == 1:
		j = 1
		break
	if x == 2:
		if p[0] != p[1]:
			j = 2
		else:
			j = 1
		break
	if i != x - 1:
		if p[i] == p[i + 1]:
			c = 1
		else:
			c = 1
			for k in range(i, i + 1):
				p[k] = k
				j = j + c
	elif i == x - 1:
		j = j + c
print(j)


from sys import stdin
n = int(input())
magnet = ''.join(map(lambda x: x[0], stdin.readlines()))
ans = magnet.count('01') + magnet.count('10') + 1
print(ans)


n = int(input())
s = [input() for i in range(n)]
ans = 1
if len(s) > 1:
	t0 = s[0]
	i = 1
	while True:
		if i < len(s):
			t1 = s[i]
			if t0[1] == t1[0]:
				ans += 1
			t0 = t1
			i += 1
		else:
			break
print(ans)


n = int(input())
x1 = input()
ans = 1
for i in range(1, n):
	x2 = input()
	if x1 != x2:
		ans += 1
	x1 = x2
print(ans)


s = []
c = 1
for _ in range(int(input())):
	a = int(input())
	if len(s) == 0:
		s.append(a)
	else:
		if s[-1] != a:
			c += 1
		s.append(a)
print(c)


st = int(input())
count = 1
last_mm = ''
for i in range(st):
	mm = input()
	if i == 0:
		last_mm = mm
		continue
	if mm[-1] == last_mm[0]:
		count += 1
	last_mm = mm
print(count)


n = int(input())
s = []
for i in range(n):
	s.append(input())
groups = 1
for i in range(1, n):
	if s[i - 1] == s[i]:
		continue
	else:
		groups += 1
print(groups)


n = int(input())
j = 0
k = '11'
for i in range(n):
	x = input()
	if x != k:
		j += 1
		k = x
print(j)


n = int(input())
prev = input()
r = 1
for i in range(1, n):
	next = input()
	if next[0] == prev[1]:
		r += 1
	prev = next
print(r)


from sys import stdin
input = stdin.readline
k = int(input())
magnut = [input() for _ in range(k)]
total = 0
for i in range(k - 1):
	if magnut[i][0] != magnut[i + 1][0]:
		total += 1
print(total + 1)


from sys import stdin
g = 0
l = 'x'
for _ in range(int(stdin.readline().strip())):
	c = stdin.readline().strip()[-1]
	if c != l:
		g += 1
	l = c
print(g)


n = int(input())
p = int(input())
g = 1
q = p
while n > 1:
	p = int(input())
	if q != p:
		g += 1
	q = p
	n -= 1
print(g)


veces = int(input())
anterior = 0
contador = 0
for i in range(veces):
	actual = int(input())
	if actual != anterior:
		contador += 1
		anterior = actual
print(contador)


n = int(input())
a = ''
b = ''
for i in range(n):
	a = input()
	b = b + a
b = b.replace('00', '0 0')
b = b.replace('11', '1 1')
b = len(b.split())
print(b)


n = int(input())
s1 = ''
for i in range(n):
	s = str(input())
	s1 = s1 + s
print(s1.count('00') + s1.count('11') + 1)


n = int(input())
b = 0
a = ''
for i in range(n):
	pD = input()
	if pD == '10' and a == '10':
		b = b + 0
	elif pD == '01' and a == '01':
		b = b + 0
	else:
		b = b + 1
	a = ''
	a = a + pD
print(b)


n = int(input())
grp = 1
prev = input()
for i in range(n - 1):
	ip = input()
	if ip != prev:
		grp += 1
		prev = ip
print(grp)


from sys import stdin
n = int(stdin.readline().strip())
count = 0
var = stdin.readline().strip()
for i in range(n - 1):
	read = stdin.readline().strip()
	if var != read:
		count += 1
		var = read
print(count + 1)


count = 1
prev = 0
for i in range(int(input())):
	s = input()
	if i != 0 and prev[1] == s[0]:
		count += 1
	prev = s
print(count)


n = int(input())
temp = '-1'
num = 1
for i in range(n):
	s = input()
	if s[0] != temp and temp != '-1':
		num += 1
	temp = s[0]
print(num)


n = int(input())
k = 0
a = 0
for i in range(n):
	prev = a
	a = int(input())
	if a == 0 or a == prev:
		continue
	else:
		k += 1
print(k)


n = int(input())
magnets = []
for _ in range(n):
	magnets.append(input())
magnet_index = 1
number_groups = 1
while magnet_index < n:
	if magnets[magnet_index][0] == magnets[magnet_index - 1][1]:
		number_groups += 1
	else:
		pass
	magnet_index += 1
print(number_groups)


TN = 1

def solution():
	n = int(input())
	s = list(input())
	cur = s[-1]
	ans = 1
	for i in range(n - 1):
		s = list(input())
		if cur == s[0]:
			ans += 1
		cur = s[-1]
	print(ans)
while TN != 0:
	solution()
	TN -= 1


T = int(input())
A = []
for _ in range(0, T):
	S = int(input())
	A.append(S)
cnt = 0
res = 0
for i in range(T):
	if A[i] != cnt:
		cnt = A[i]
		res += 1
print(res)


n = int(input())
a = []
l = []
matrix = []
count = 1
count = int(count)
j = 1
for i in range(n):
	a.append(input(''))
for i in range(n):
	s = a[i][0]
	l.append(a[i].lstrip(s))
for i in range(n - 1):
	if l[i] == l[i + 1]:
		continue
	else:
		count += 1
print(count, end='')


x = int(input())
c = 0
y = 0
while x > 0:
	x -= 1
	k = int(input())
	if y != k:
		y = k
		c += 1
print(c)


n = int(input())
c = 0
w = int(input())
n = n - 1
for s in range(n):
	e = int(input())
	if e != w:
		c = c + 1
		w = e
print(c + 1)


n = int(input())
c = 1
v = input()
for i in range(n - 1):
	x = input()
	if x != v:
		c += 1
		v = x
print(c)


n = int(input())
previous = input()
ans = 1
for i in range(1, n):
	magnet = input()
	if previous != magnet:
		ans += 1
		previous = magnet
print(ans)


n = int(input())
mag = []
isl = 0
for i in range(n):
	mag.append(int(input()))
for i in range(n):
	if i == n - 1 and mag[i] != mag[i - 1]:
		break
	elif i == n - 1 and mag[i] == mag[i - 1]:
		break
	elif mag[i + 1] == mag[i]:
		continue
	else:
		isl += 1
print(isl + 1)


n = int(input())
count = 0
text = ''
for i in range(n):
	str = input()
	if text != str:
		count += 1
	text = str
print(count)


n = int(input())
ctr = 1
for i in range(n):
	curr = input()
	if i and curr != prev:
		ctr += 1
	prev = curr
print(ctr)


n = int(input())
arr = []
for m in range(n):
	arr.append(input())
i = 0
next_m = i + 1
group = 1
while i < len(arr) - 1:
	if arr[i] == arr[next_m]:
		i += 1
		next_m += 1
	else:
		group += 1
		i += 1
		next_m += 1
print(group)


t = int(input())
s = ''
c = 1
for i in range(t):
	s = s + input()
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		c += 1
print(c)


c = 0
d = 0
for i in range(int(input())):
	temp = int(input())
	if temp != d:
		c += 1
	d = temp
print(c)


n = int(input())
island = 0
b = 0
for i in range(1, n + 1):
	x = input()
	if x != b:
		island += 1
	b = x
print(island)


t = int(input())
lst = []
while t:
	t -= 1
	lst.append(int(input()))
x = lst[0]
c = 1
i = 0
while i < len(lst):
	if lst[i] != x:
		c += 1
		x = lst[i]
		i += 1
	else:
		i += 1
print(c)


n = int(input())
counter = 1
frist_magnet = input()
for i in range(n - 1):
	magnet = input()
	if magnet != frist_magnet:
		counter += 1
		frist_magnet = magnet
print(counter)


n = input()
magnet = []
for i in range(int(n)):
	magnet.append(input())
count = 0
compared_str = magnet[0]
for i in range(int(n)):
	if magnet[i] != compared_str:
		count += 1
		compared_str = magnet[i]
print(count + 1)


def magnet(string):
	prev_char = ''
	count_groups = 1
	for char in string:
		if prev_char == char:
			count_groups += 1
		prev_char = char
	return count_groups
a = input()
input_str = ''
for i in range(int(a)):
	a = input()
	input_str += a
print(magnet(input_str))


n = int(input())
n1 = input()
s = n1[0]
e = n1[1]
lc = 1
for i in range(1, n):
	n1 = input()
	if n1[0] == e:
		lc += 1
		s = n1[0]
		e = n1[1]
print(lc)


n = int(input())
a = []
j = 1
for i in range(0, n):
	x = int(input())
	a.append(x)
for i in range(n - 1):
	if a[i] == a[i + 1]:
		pass
	else:
		j = j + 1
print(j)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
c = 0
if len(l) == 1:
	print(1)
else:
	for i in range(n - 1):
		if l[i] != l[i + 1]:
			c += 1
	print(c + 1)


n = int(input())
count = 0
q = 0
for _ in range(n):
	q1 = int(input())
	if q1 != q:
		count += 1
		q = q1
print(count)


n = int(input())
a = [' ']
c = 0
for _ in range(n):
	s = input()
	if s != a[-1]:
		a.append(s)
		c += 1
print(c)


n = input()
groups = 1
data = []
for x in range(0, int(n)):
	data.append(input())
for p in range(0, len(data) - 1):
	if data[p + 1][:1] == data[p][1:]:
		groups += 1
print(groups)


s = int(input())
count = 0
l = []
m = input()
t = m[1]
for i in range(1, s):
	r = input()
	a = r[0]
	if t == a:
		count = count + 1
		t = r[1]
	else:
		t = r[1]
print(count + 1)


n = int(input())
p = input()
ans = 1
for i in range(n - 1):
	q = input()
	if p[1] == q[0]:
		ans += 1
		p = q
print(str(ans))


n = int(input())
l = []
ma = '00'
num = 0
for i in range(n):
	l.append(input())
for i in l:
	if i == ma:
		continue
	else:
		num += 1
		ma = i
print(num)


import sys
n = int(input(''))
flag = 0
cont = 0
if n < 1 or n > 100000:
	sys.exit(0)
for i in range(0, n):
	ima = int(input(''))
	if ima != flag:
		cont += 1
	flag = ima
print(cont)


n = int(input())
current = int(input())
ans = 0
for i in range(n - 1):
	next = int(input())
	if next != current:
		ans += 1
	current = next
ans += 1
print(ans)


def main():
	groups = 1
	magnet_count = int(input())
	magnets = []
	for i in range(magnet_count):
		magnet_type = input()
		magnets.append(magnet_type)
		if i > 0:
			if magnet_type[0] != magnets[i - 1][0]:
				groups += 1
	print(groups)
main()


(islands, previous) = (0, '')
for _ in range(int(input())):
	current = input()
	if current != previous:
		islands += 1
	previous = current
print(islands)


n = int(input())
lst = list()
out = list()
s = 1
for i in range(n):
	lst.append(input())
for i in range(n):
	if i == 0:
		continue
	if lst[i] != lst[i - 1]:
		s = s + 1
print(s)


n = int(input())
before = '00'
group = 0
for i in range(n):
	magnet = input()
	if magnet != before:
		group += 1
		before = magnet
print(group)


c = 0
b = ''
for i in range(int(input())):
	a = input()
	if not b:
		c += 1
		b = a
	elif b[-1] == a[0]:
		c += 1
		b = a
	else:
		b = a
print(c)


n = int(input())
prev = 0
answer = 0
for i in range(n):
	new = int(input())
	if new == prev:
		prev = new
	else:
		prev = new
		answer += 1
print(answer)


n = int(input())
col = 0
last = '00'
for i in range(n):
	e = input()
	col += 1 if e != last else 0
	last = e
print(col)


from collections import defaultdict
n = int(input())
s = []
for i in range(n):
	s.append(input())
curr = s[0]
count = 0
for i in range(1, n):
	if curr[1] == s[i][0]:
		count += 1
	curr = s[i]
print(count + 1)


n = int(input())
counter = 1
first = input()
for i in range(n - 1):
	previous = input()
	if first[-1] == previous[0]:
		counter = counter + 1
	first = previous
print(counter)


n = int(input())
(start, end, groups) = ('', input()[-1], 1)
for i in range(1, n):
	start = input()
	if start[0] == end:
		groups += 1
	end = start[-1]
print(groups)


prothom_shongkha = int(input())
talika = []
talika2 = []
for i in range(prothom_shongkha):
	talika.append(input())
for i in range(prothom_shongkha - 1):
	if talika[i] != talika[i + 1]:
		talika2.append(talika[i])
if len(talika2) == 0:
	print(1)
else:
	print(len(talika2) + 1)


import sys
input = sys.stdin.readline
n = int(input())
l = 0
cur = 0
for x in range(n):
	c = int(input())
	if c != l:
		l = c
		cur += 1
print(cur)


n = int(input())
num_list = []
for i in range(n):
	num_list.append(int(input()))
count = 1
first = num_list[0]
for i in range(1, n):
	if num_list[i] == first:
		continue
	else:
		first = num_list[i]
		count += 1
print(count)


n = int(input())
lx = list()
for i in range(n):
	p = input()
	lx.append(p)
c = 1
for i in range(len(lx)):
	if i == n - 1:
		break
	if lx[i] == '10':
		if lx[i + 1] == '10':
			continue
		else:
			c = c + 1
	elif lx[i] == '01':
		if lx[i + 1] == '01':
			continue
		else:
			c = c + 1
print(c)


n = int(input())
l = []
ans = 1
for f in range(n):
	l.append(input())
for f in range(n - 1):
	if l[f] != l[f + 1]:
		ans += 1
print(ans)


n = int(input())
l = []
c = 1
for _ in range(n):
	l.append(str(input()))
for i in range(len(l) - 1):
	if l[i] == '10' and l[i + 1] == '01':
		c += 1
	if l[i] == '01' and l[i + 1] == '10':
		c += 1
print(c)


from sys import stdin, stdout
q = int(input())
last = 'x'
blocks = 0
for _ in range(q):
	m = input()
	if last != m[1]:
		blocks += 1
		last = m[1]
print(blocks)


n = int(input())
l = [int(input()) for i in range(n)]
static = l[0]
group = 0
for i in l:
	if i != static:
		group += 1
		static = i
print(group + 1)


n = int(input())
L = [input() for k in range(n)]
cont = 1
for k in range(n - 1):
	if L[k][1] == L[k + 1][0]:
		cont += 1
print(cont)


n = int(input())
m = n
while n != 0:
	if n == m:
		b = int(input())
		s = 1
	else:
		v = b
		b = int(input())
		if b != v:
			s += 1
			v = b
	n = n - 1
print(s)


n = int(input())
fq = [0] * n
for i in range(n):
	fq[i] = input()
s = 1
k = 0
d = 1
while k < n - 1:
	if fq[k] != fq[k + 1]:
		s += 1
		d = max(d, s)
	k += 1
print(d)


n = int(input())
ss = input()
r = int(ss[1])
n -= 1
cnt = 0
while n:
	ss = input()
	if r == int(ss[0]):
		cnt += 1
	r = int(ss[1])
	n -= 1
print(cnt + 1)


p = []
d = 0
for _ in range(int(input())):
	n = int(input())
	p.append(n)
for i in range(len(p) - 1):
	if p[i] != p[i + 1]:
		d = d + 1
print(d + 1)


from itertools import groupby
from sys import stdin
n = int(input())
mag = []
for i in range(n):
	s = stdin.readline()
	mag.append(s)
mag = groupby(mag)
new_mag = []
for (elem, grouper) in mag:
	new_mag.append(list(grouper))
print(len(new_mag))


magnets = int(input())
last = '-'
groups = 0
for i in range(magnets):
	mag = input()
	if mag != last:
		last = mag
		groups += 1
print(groups)


n = int(input())
x = 1
y = input()
while n - 1 != 0:
	z = input()
	if y != z:
		x += 1
	n -= 1
	y = z
print(x)


n = int(input())
sv = 1
for i in range(n):
	s = input()
	if i != 0:
		if s != ab:
			sv += 1
	ab = s
print(sv)


n = int(input())
a = []
for _ in range(n):
	a.append(input())
flag = 0
g = 1
for i in range(n - 1):
	if a[i] == '01' and a[i + 1] == '10' or (a[i] == '10' and a[i + 1] == '01'):
		g += 1
print(g)


n = int(input())
m = 0
s = 1
for i in range(n):
	l = m
	m = int(input())
	if m != l and i != 0:
		s += 1
		l = m
print(s)


n = input()
pervios = 0
result = 0
for i in range(int(n)):
	magent = input()
	if int(magent) != pervios:
		result += 1
		pervios = int(magent)
print(result)


n = int(input())
o = 0
f = ''
for i in range(n):
	m = input()
	if m != f:
		o += 1
		f = m
print(o)


n = int(input().strip('\n\r\t '))
parts = 1
c = None
for _i in range(0, n):
	tmp = input()
	if c == tmp[0]:
		parts += 1
	c = tmp[1]
print(parts)


n = int(input())
x = ''
count = 1
while n != 0:
	x += input()
	n -= 1
for (index, element) in enumerate(x, start=1):
	if index + 1 == len(x):
		break
	elif x[index] == x[index + 1]:
		count += 1
print(count)


n = int(input())
val = 0
(cur, prev) = ('00', '00')
for i in range(n):
	cur = input()
	if cur != prev:
		val += 1
	prev = cur
print(val)


n = int(input())
q = []
group = 0
for i in range(n):
	a = int(input())
	q.append(a)
for j in range(n - 1):
	if q[j] != q[j + 1]:
		group += 1
	else:
		continue
print(group + 1)


n = int(input())
c = 1
s = input()
for i in range(1, n):
	m = input()
	if m == s:
		pass
	else:
		c = c + 1
		s = m
print(c)


n = int(input())
b = ''
for _ in range(n):
	a = input()
	b += a
c = 1
for i in range(1, len(b)):
	if b[i] == b[i - 1]:
		c += 1
print(c)


n = int(input())
groups = 1
lis = []
for i in range(n):
	s = input()
	lis.append(s)
for i in range(n - 1):
	if lis[i] == lis[i + 1][::-1]:
		groups += 1
print(groups)


n = int(input())
count = 0
q = input()
for i in range(n - 1):
	str1 = input()
	if q[1] == str1[0]:
		count += 1
	q = str1
print(count + 1)


n = int(input())
l = []
a = []
b = []
for i in range(n):
	m = int(input())
	l.append(m)
for i in range(n - 1):
	if l[i] == l[i + 1]:
		b.append(2)
	if l[i] != l[i + 1]:
		a.append(1)
if n == 1:
	print(1)
elif len(b) == n - 1:
	print(1)
else:
	print(len(a) + 1)


t = int(input())
p1 = input()
count = 0
for i in range(t - 1):
	p2 = input()
	if p1 != p2:
		count += 1
	p1 = p2
print(count + 1)


n = int(input())
a = ''
for i in range(n):
	a += input()
x = a.count('00')
y = a.count('11')
print(x + y + 1)


c = 1
x = 0
i = int(input())
pre = input()
while x < i - 1:
	j = input()
	if j != pre:
		c += 1
		pre = j
	else:
		pre = j
	x += 1
print(c)


n = int(input())
m = n
s = []
for j in range(n):
	s.append(input())
for i in range(n - 1):
	if s[i] == s[i + 1]:
		m -= 1
print(m)


magnets = int(input())
(group, temp) = (0, 0)
for _ in range(magnets):
	magnets = int(input())
	if magnets != temp:
		group += 1
	temp = magnets
print(group)


a = int(input())
i = j = input()
m = 1
for item in range(a - 1):
	i = input()
	if i != j:
		m += 1
	else:
		m = m
	j = i
print(m)


n = int(input())
l = input()
g = 1
for x in range(1, n):
	t = input()
	if l != t:
		g += 1
	l = t
print(g)


n = int(input())
s = ''
count = 1
for i in range(n):
	s = s + input()
for i in range(1, len(s), 2):
	if i + 1 < len(s) and s[i] == s[i + 1]:
		count += 1
print(count)


from sys import stdin, stdout
from math import ceil
from collections import deque
inp = stdin.readline
out = stdout.write
n = int(inp().strip())
p = inp().strip()
c = 1
for i in range(n - 1):
	s = inp().strip()
	if p[-1] == s[0]:
		c += 1
	p = s
print(c)


num = int(input())
a = 0
b = 0
c = 0
i = 0
while i < num:
	a = int(input())
	i = i + 1
	if a != b:
		c = c + 1
		b = a
print(c)


n = int(input())
list = []
for i in range(n):
	list.append(input())
	i = i + 1
count = 1
j = 0
for j in range(len(list) - 1):
	if list[j] != list[j + 1]:
		count = count + 1
	j = j + 1
print(count)


n = int(input())
ans = 0
init = 0
for i in range(n):
	m = input()
	if m != init:
		ans += 1
	init = m
print(ans)


n = int(input())
magnet = [''] * n
for i in range(0, n):
	magnet[i] = str(input())
grouped = 1
for i in range(0, n - 1):
	if magnet[i][1] == magnet[i + 1][0]:
		grouped = grouped + 1
print(grouped)


n = int(input())
temp = '22'
count = 1
for i in range(0, n):
	s = input()
	if temp[1] == s[0]:
		count += 1
	temp = s
print(count)


def countmag(l):
	(prev, count) = ('', 0)
	for x in l:
		if x != prev:
			count += 1
			prev = x
	return count
n = int(input())
l = list()
for x in range(n):
	l.append(input())
print(countmag(l))


n = int(input())
count = 0
prev = ''
for i in range(n):
	mag = input()
	if mag == prev:
		continue
	count += 1
	prev = mag
print(count)


n = int(input())
i = []
while len(i) < n:
	i.append(int(input()))
c = 0
x = 1
while c < len(i):
	if c + 1 != len(i):
		if i[c] == i[c + 1]:
			c += 1
		else:
			x += 1
			c += 1
	else:
		break
print(x)


x = int(input())
y = []
for i in range(x):
	y.append(input())
z = [0] * x
z[0] = 1
for i in range(1, x):
	if y[i] == y[i - 1]:
		z[i] = z[i - 1] + 1
	elif y[i] != y[i - 1]:
		z[i] = 1
total = 0
for i in range(len(z)):
	if z[i] == 1:
		total = total + 1
print(total)


n_i = int(input())
l_i = []
c = 1
for i in range(n_i):
	l_i.append(input())
if len(l_i) == 1:
	c = 1
	print(c)
else:
	for i in range(len(l_i) - 1):
		if l_i[i][1] == l_i[i + 1][0]:
			c += 1
	print(c)


n = int(input())
l = []
k = 1
for i in range(n):
	l.append(input())
for (i, item) in enumerate(l):
	if i + 1 < len(l):
		if item != l[i + 1]:
			k += 1
		else:
			continue
print(k)


n = int(input())
string = ''
for i in range(n):
	string += input()
o = 0
string = list(string)
for i in range(n * 2 - 1):
	if string[i] == string[i + 1]:
		o += 1
print(o + 1)


s = ''
n = 1
for i in range(int(input())):
	ch = input()
	try:
		if ch[0] == s[-1]:
			n += 1
	except:
		pass
	s += ch
print(n)


n = int(input())
magnet = []
count = 1
for i in range(n):
	m = input()
	magnet.append(m)
i = 0
while i < len(magnet) - 1:
	if magnet[i] == magnet[i + 1]:
		i += 1
	else:
		count += 1
		i += 1
print(count)


n = int(input())
pertama = input()
total = 1
for i in range(n - 1):
	kedua = input()
	if pertama != kedua:
		total += 1
	pertama = kedua
print(total)


count = int(input())
arr = [0] * count
arr[0] = input()
res = 1
for i in range(1, count):
	arr[i] = input()
	if arr[i] != arr[i - 1]:
		res += 1
print(res)


n = int(input())
fe = n * [0]
long = n * [1]
value = 1
for i in range(n):
	fe[i] = [int(t) for t in list(input())]
for i in range(1, n):
	if fe[i - 1][1] + fe[i][0] != 1:
		value += 1
print(value)


st = ''
r = []
n = int(input())
l = []
for i in range(n):
	s = input().strip()
	l.append(s[0])
r.append(l[0])
for i in range(1, len(l)):
	if l[i] != l[i - 1]:
		r.append(l[i])
print(len(r))


num_magnets = int(input())
magnet_seq = ''
for _ in range(num_magnets):
	magnet_seq += input()
print(1 + magnet_seq.count('00') + magnet_seq.count('11'))


old = ''
c = 0
for i in range(int(input())):
	new = input()
	if old != new:
		c += 1
	old = new
print(c)


cnt = 1
n = int(input())
n1 = input()
for i in range(n - 1):
	n2 = input()
	if n1 != n2:
		cnt += 1
	n1 = n2
print(cnt)


x = input()
x = int(x)
a = input()
p = int(1)
for i in range(x - 1):
	b = input()
	if a == b:
		continue
	else:
		a = b
		p = p + 1
		continue
print(p)


n = int(input())
p = k = 0
for _ in range(n):
	x = input()
	if x != p:
		k += 1
	p = x
print(k)


import math
from collections import defaultdict
from collections import Counter
import itertools

def solve(A):
	n = len(A)
	c = 0
	for i in range(n - 1):
		if A[i] != A[i + 1]:
			c += 1
	return c + 1
n = int(input())
temp = []
while n:
	in_ = input()
	temp.append(in_)
	n -= 1
print(solve(temp))


Lines = int(input())
count = 1
Magnets = [input() for Line in range(0, Lines)]
for x in range(0, Lines - 1):
	if Magnets[x] != Magnets[x + 1]:
		count += 1
print(count)


withFile = 0
if withFile == 1:
	fin = open('input.txt', 'r')
	fout = open('output.txt', 'w')

def getl():
	if withFile == 0:
		return input()
	else:
		return fin.readline()

def printl(s):
	if withFile == 0:
		print(s)
	else:
		fout.write(str(s))

def get_arr():
	x = getl().split(' ')
	if x[-1] == '':
		x = x[:-1]
	return list(map(int, x))
n = get_arr()[0]
c = 1
a = []
while n:
	n -= 1
	s = getl()
	if len(a) == 0 or a[-1] == s:
		a.append(s)
	else:
		a = []
		a.append(s)
		c += 1
printl(c)
if withFile == 1:
	fin.close()
	fout.close()


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	N = Scanner.int()
	cur = Scanner.string()
	ans = 1
	for _ in range(N - 1):
		s = Scanner.string()
		if cur != s:
			ans += 1
			cur = s
	print(ans)
main()


nStr = input()
n = int(nStr)
group = 0
crtPole = ''
for i in range(n):
	poleIn = input()
	if poleIn != crtPole:
		group = group + 1
		crtPole = poleIn
print(group)


number = int(input())
n = 0
c = ''
groups = 1
while n < number:
	current = input()
	if n == 0:
		c = current
	elif current != c:
		groups += 1
		c = current
	n += 1
print(groups)


n = int(input())
a = []
c = 1
for x in range(n):
	a.append(int(input()))
for x in range(n - 1):
	if a[x] != a[x + 1]:
		c += 1
print(c)


x = int(input())
y = []
for i in range(x):
	y.append(input())
y = ''.join(y)
count = 1
for i in range(len(y) - 1):
	if y[i] == '0' and y[i + 1] == '0' or (y[i] == '1' and y[i + 1] == '1'):
		count += 1
print(count)


l = []
for i in range(int(input())):
	s = input()
	l.append(s)
c = 1
for i in range(len(l) - 1):
	if l[i] == l[i + 1]:
		pass
	else:
		c += 1
print(c)


n = int(input())
lst = list()
for i in range(n):
	data = int(input())
	lst.append(int(data))
count = 0
j = 0
while j < len(lst) - 1:
	if lst[j] != lst[j + 1]:
		count = count + 1
	j = j + 1
print(count + 1)


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
groups = 1
for i in range(len(arr) - 1):
	if arr[i] == '10':
		if arr[i + 1] == '01':
			groups += 1
	elif arr[i] == '01':
		if arr[i + 1] == '10':
			groups += 1
print(groups)


n = int(input())
A = []
for i in range(0, n):
	a = input()
	A.append(a)
count = 1
for j in range(0, n - 1):
	if A[j] != A[j + 1]:
		count = count + 1
print(count)


n = int(input())
a = input()
hey = [a]
groups = 1
for i in range(n - 1):
	f = input()
	hey.append(f)
	if hey[i][1] == f[0]:
		groups += 1
print(groups)


n = int(input())
result = ''
counter = 1
for i in range(0, n):
	reg = input()
	result += reg
a = 0
while a <= len(result) - 4:
	if result[a] != result[a + 2]:
		counter += 1
	a += 2
print(counter)


n = int(input())
x = []
for i in range(n):
	x.append(input())
(i, g) = (0, 0)
j = 1
while int(j) < len(x):
	p = x[i]
	n = x[j]
	if p != n:
		g += 1
	i = j
	j += 1
print(g + 1)


n = int(input())
res = 1
w = input()
last = w

def func(n, last, res=1):
	for i in range(1, n):
		w = input()
		if last != w:
			res += 1
			last = w
	print(res)
func(n, last)


def main():
	n = int(input())
	string = str(input())
	cnt = 1
	for _ in range(n - 1):
		temp = str(input())
		if string[1] == temp[0]:
			cnt += 1
		string = temp
	print(cnt)
main()


n = input()
x = []
count = 1
e = 0
for i in range(int(n)):
	y = input()
	x.append(y)
for i in x:
	if e < int(n) - 1:
		if x[e] != x[e + 1]:
			count = count + 1
		e = e + 1
print(count)


import sys
cases = int(input())
word = ''
while cases:
	word += str(input())
	cases -= 1
count1 = word.count('00')
count2 = word.count('11')
result = count1 + count2 + 1
print(result)
sys.exit()


magnets_count = int(input())
groups_count = 1
previous_input = ''
for i in range(0, magnets_count):
	user_input = input()
	if previous_input == '01' and user_input == '10' or (previous_input == '10' and user_input == '01'):
		groups_count += 1
	previous_input = user_input
print(groups_count)


n = int(input())
b = []
ilands = 1
for i in range(n):
	a = input()
	if a == '01':
		b.append(0)
	elif a == '10':
		b.append(1)
for i in range(1, len(b)):
	b1 = b[i - 1]
	b2 = b[i]
	if b1 != b2:
		ilands += 1
print(ilands)


n = int(input())
last = 'qwerty'
groups = 0
for x in range(0, n):
	magnet = input()
	if magnet != last:
		last = magnet
		groups += 1
print(groups)


n = int(input())
sets = []
groups = 1
for i in range(0, n):
	mag = input()
	sets.append(mag)
counter = 1
for element in range(0, len(sets) - 1):
	if sets[element] != sets[counter]:
		groups += 1
		counter += 1
	else:
		counter += 1
print(groups)


n = int(input())
list = []
for x in range(n):
	list.append(int(input()))
list.append(0)
count = 0
for x in range(len(list) - 1):
	if list[x] != list[x + 1]:
		count += 1
print(count)


r = input
n = int(r())
s = ''
for _ in [0] * n:
	s += r()
print(sum((1 for (i, j) in zip(s[1:], s) if i == j)) + 1)


n = int(input())
mag = []
mag.append(input())
count = 1
for i in range(n - 1):
	mag.append(input())
	if mag[-1] == mag[-2]:
		count = count
	else:
		count += 1
print(count)


n = int(input())
i = 0
arr = []
g = 1
while i < n:
	v = int(input())
	arr.append(v)
	if arr[i] == arr[i - 1]:
		g = g
	else:
		g = g + 1
	i = i + 1
print(g)


n = int(input())
s = ''
for i in range(n):
	a = input()
	s = s + a
s1 = s.count('11')
s2 = s.count('00')
print(s1 + s2 + 1)


n = int(input())
mylist = []
for i in range(n):
	num = int(input())
	mylist.append(num)
magnet = 0
groups = 0
for i in mylist:
	if i != magnet:
		groups += 1
		magnet = i
print(groups)


n = int(input())
prev = -1
cnt = 0
for i in range(n):
	t = int(input())
	if prev == -1 or t != prev:
		prev = t
		cnt += 1
print(cnt)


n = int(input())
counter = 1
temp = ''
for i in range(n):
	d = input()
	if temp and temp[1] == d[0]:
		counter += 1
	temp = d
print(counter)


n = int(input())
brk = 0
prev = '##'
for _ in range(n):
	magnet_orientation = input()
	if prev[-1] == magnet_orientation[0]:
		brk += 1
	prev = magnet_orientation
print(brk + 1)


x = int(input())
groups = 0
lst = []
for i in range(x):
	lst.append(input())
for i in range(len(lst) - 1):
	groups += lst[i] != lst[i + 1]
print(groups + 1)


n = int(input())
li = []
for i in range(n):
	x = input()
	li.append(x)
lis = []
d = 0
c = 0
for i in range(n):
	if i == n - 1:
		lis.append(c)
		break
	if li[i] == li[-(n - 1 - i)]:
		c += 1
	else:
		lis.append(c)
		c = 0
l = len(lis)
print(l)


from sys import stdin
n = int(stdin.readline())
prev = int(stdin.readline())
grp = 1
for i in range(n - 1):
	curr = int(stdin.readline())
	if curr != prev:
		grp += 1
	prev = curr
print(grp)


num_magnet = int(input())
matrix = []
for i in range(0, num_magnet):
	matrix.append(input())
compare_value = matrix[0]
result = 0
for j in range(len(matrix)):
	if compare_value != matrix[j]:
		result += 1
		compare_value = matrix[j]
result += 1
print(result)


magnets = list((int(input()) for _ in range(int(input()))))
count = 1 + sum((magnets[i] - magnets[i + 1] != 0 for i in range(len(magnets) - 1)))
print(count)


in0 = int(input())
in1 = 0
in3 = 0
for x in range(in0):
	in2 = int(input())
	if in2 != in1:
		in1 = in2
		in3 += 1
print(in3)


n = int(input())
a = []
flag = 0
for i in range(n):
	a.append(input())
for i in range(n - 1):
	if a[i][0] == a[i + 1][0]:
		continue
	if a[i][0] != a[i + 1][0]:
		flag += 1
print(flag + 1)


import sys
for s in sys.stdin:
	tot = 1
	for i in range(0, int(s)):
		if i == 0:
			pretest = input()
		else:
			test = input()
			if test != pretest:
				tot += 1
			pretest = test
	print(tot)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

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

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
ans = 1
l = stdin.readlines()
x = l[0]
for i in range(1, n):
	if x != l[i]:
		ans += 1
	x = l[i]
print(ans)


n = int(input())
mag = []
islands = 1
for i in range(n):
	mag.append(str(input()))
for j in range(1, n):
	if mag[j][0] == mag[j - 1][1]:
		islands += 1
print(islands)


def bublesort(a):
	n = len(a)
	fl1 = False
	while not fl1:
		fl1 = True
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				fl1 = False

def isgood(a):
	k = 0
	for x in a:
		if x == 'a':
			k += 1
	return k > len(a) // 2

def dell(a):
	k = 0
	for x in a:
		if x != 'a':
			return a[:k] + a[k + 1:]
		k += 1

def pl2d(a):
	for t in a:
		for x in t:
			print(x, end=' ')
		print()

def foundm(x, a, row, col):
	for i in range(row):
		for j in range(col):
			if a[i][j] == x:
				return (i, j)

def swaprow(a, n1, n2):
	(a[n1], a[n2]) = (a[n2], a[n1])

def swapcol(a, k1, k2):
	for lst in a:
		swaprow(lst, k1, k2)

def prlist(a):
	for x in a:
		print(x, end=' ')
x = int(input())
k = 0
q = 22
for i in range(x):
	w = q
	q = int(input())
	if q != w:
		k += 1
print(k)


i = int(input())
a = int(input())
l = a
p = 1
for u in range(0, i - 1):
	b = int(input())
	if b != l:
		p += 1
		l = b
print(p)


n = int(input())
num = 1
m = input()
for i in range(1, n):
	s = input()
	if s == m:
		continue
	else:
		num += 1
		m = s
print(num)


from sys import stdin, stdout
t = int(input())
islands = 1
current = input()
for i in range(t - 1):
	test = stdin.readline().rstrip()
	if current != test:
		islands += 1
		current = test
print(islands)


n = int(input())
k = 1
line = ''
for i in range(n):
	line += input()
for i in range(len(line) - 1):
	if line[i] == line[i + 1]:
		k += 1
print(k)


n = int(input())
for i in range(n):
	if i == 0:
		grp = 1
		omg = input().strip()
	else:
		nmg = input().strip()
		if omg[-1] == nmg[0]:
			grp += 1
		omg = nmg
print(grp)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
print(sum((l[i] != l[i + 1] for i in range(n - 1))) + 1)


n = int(input())
temp = ''
ct = 0
for i in range(n):
	q = input()
	if q != temp:
		ct += 1
		temp = q
print(ct)


n = int(input())
ans = 0
temp = input()
last = temp[len(temp) - 1]
ans += 1
for i in range(n - 1):
	temp = input()
	if temp[0] == last:
		ans += 1
	last = temp[len(temp) - 1]
print(ans)


number = int(input())
group = 0
a = 0
for i in range(number):
	(a, b) = (int(input()), a)
	if a == b:
		group = group
	else:
		group += 1
print(group)


n = int(input())
cont = 1
ref = 'x'
for i in range(n):
	x = input()
	if x[0] == ref:
		cont += 1
	ref = x[1]
print(cont)


n = int(input())
s = 1
position = []
for i in range(n):
	position.append(str(input()))
for j in range(1, n):
	if position[j] != position[j - 1]:
		s = s + 1
print(s)


t = int(input())
s = 0
c = 0
for i in range(t):
	x = input()
	if x != s:
		c += 1
		s = x
print(c)


g = 0
t = int(input())
for i in range(0, t):
	n = input()
	if i == 0:
		g += 1
	elif s[1] == n[0]:
		g += 1
	s = n
print(g)


import sys
n = sys.stdin.readline()
s2 = ''
s = 1
for i in range(int(n)):
	s1 = s2
	s2 = sys.stdin.readline()
	if s1 and s1 != s2:
		s += 1
print(s)


num = int(input())
a = []
cnt = 1
for i in range(num):
	a.append(input())
	if len(a) == 1:
		pass
	elif a[i][0] == a[i - 1][1]:
		cnt += 1
print(cnt)


n = int(input())
l = [input() for i in range(n)]
groups = 1
for (a, b) in zip(l, l[1:]):
	if a != b:
		groups += 1
print(groups)


n = int(input())
num = 1
k = []
for i in range(n):
	a = input()
	if a == '01':
		key = 0
		k.append(key)
	else:
		key = 1
		k.append(key)
for j in range(n - 1):
	if k[j + 1] == k[j]:
		num += 0
	else:
		num += 1
print(num)


n = int(input())
a = ''
while n > 0:
	i = input()
	a = a + i
	n = n - 1
x = 1
y = 2
z = 1
while y < len(a) - 1:
	if a[x] == a[y]:
		z = z + 1
	x = x + 2
	y = y + 2
print(z)


lst = []
count = 1
for i in range(int(input())):
	x = int(input())
	lst.append(x)
for j in range(len(lst)):
	if j == len(lst) - 1:
		break
	else:
		k = j + 1
	if lst[j] != lst[k]:
		count += 1
print(count)


n = int(input())
X = '00'
ans = 0
for i in range(n):
	y = input()
	if X != y:
		ans += 1
	X = y
print(ans)


n = int(input())
counter = 1
for i in range(n):
	x = input()
	if i == 0:
		y = x[1]
	elif x[0] == y:
		counter += 1
		y = x[1]
	else:
		y = x[1]
print(counter)


n = int(input())
g = 0
pr = '00'
for i in range(n):
	m = input()
	g += m != pr
	pr = m
print(g)


import sys

def main():
	magnets = int(sys.stdin.readline().strip())
	piece = 1
	preHead = None
	for x in range(magnets):
		mag = sys.stdin.readline().strip()
		head = mag[0]
		tail = mag[1]
		if head is preHead:
			piece += 1
		preHead = tail
	print(piece)
main()


n = int(input())
j = []
for e in range(n):
	a = int(input())
	j.append(a)
x = 1
i = 1
if len(j) > 1:
	while i != n:
		if j[i] != j[i - 1]:
			x += 1
		i += 1
print(x)


a = int(input())
s = ''
for i in range(a):
	b = input()
	s += b
count = 0
for j in range(1, 2 * a - 2, 2):
	if s[j] == s[j + 1]:
		count += 1
print(count + 1)


n = int(input())
L = []
cnt = 1
for i in range(n):
	L.append(input())
for i in range(1, n):
	if ord(L[i][0]) - ord(L[i - 1][1]) == 0:
		cnt = cnt + 1
print(cnt)


inp = int(input())
h = 0
cont = 0
for i in range(inp):
	v = input()
	if v != h:
		cont += 1
		h = v
print(cont)


ans = 1
last = -1
for _ in range(int(input())):
	in_value = input()
	if in_value[0] == last:
		ans += 1
	last = in_value[1]
print(ans)


n = int(input())
count = 0
for i in range(n):
	poles = input()
	first_pole = poles[0]
	if i == 0:
		last_pole = poles[1]
	elif i > 0:
		if last_pole == first_pole:
			count += 1
		last_pole = poles[1]
print(count + 1)


n = int(input())
c = 1
el = input()
for i in range(1, n):
	el1 = input()
	if el1 != el:
		c += 1
	el = el1
print(c)


n = int(input())
s = ''
for i in range(n):
	s += input()
s += 'Z'
b = 0
for i in range(n * 2):
	if s[i] == s[1 + i]:
		b += 1
print(b + 1)


n = int(input())
nums = [0]
cnt = 1
for i in range(n):
	nums.append(int(input()))
for i in range(2, n + 1):
	if nums[i] != nums[i - 1]:
		cnt += 1
print(cnt)


n = int(input())
ans = 0
for i in range(0, n):
	if i == 0:
		s = input()
	else:
		s = input()
		if temp != s:
			ans += 1
	temp = s
print(ans + 1)


x = int(input())
y = []
for i in range(x):
	z = int(input())
	y.append(z)
m = 1
for n in range(len(y) - 1):
	if y[n] != y[n + 1]:
		m = m + 1
print(m)


n = int(input())
lst = []
c = 1
for i in range(n):
	lst.extend(list(map(int, input().split())))
for i in range(len(lst) - 1):
	for j in range(i + 1, i + 2):
		if lst[i] == lst[j]:
			pass
		else:
			c = c + 1
print(c)


MAGNETS_NUM = int(input())
MAGNETS_ARRAY_NUM = 0
MAGNETS_NORMAL = '00'
for i in range(0, MAGNETS_NUM):
	MAGNETS_NEW_STATUS = str(input())
	if MAGNETS_NORMAL != MAGNETS_NEW_STATUS:
		MAGNETS_ARRAY_NUM += 1
		MAGNETS_NORMAL = MAGNETS_NEW_STATUS
print(MAGNETS_ARRAY_NUM)


n = int(input())
start = input()
ostrov = 1
n -= 1
while n > 0:
	elem = input()
	if elem != start:
		ostrov += 1
		start = elem
	n -= 1
print(ostrov)


a = int(input(''))
x = 1
lt = []
for i in range(a):
	b = input('')
	lt.append(b)
for i in range(0, a - 1):
	if lt[i] != lt[i + 1]:
		x = x + 1
print(x)


n = int(input())
string = ''
for i in range(n):
	s = input()
	string += s
cnt = 0
for i in range(1, 2 * n):
	if string[i - 1] == string[i]:
		cnt += 1
print(cnt + 1)


N = int(input())
ls = []
for i in range(N):
	ls.append(input())
count = 1
for i in range(len(ls) - 1):
	if ls[i][1] == ls[i + 1][0]:
		count += 1
print(count)


n = int(input())
count = 1
lst = []
for _ in range(n):
	s1 = input()
	lst.append(s1)
for i in range(len(lst) - 1):
	s2 = str(lst[i])
	s3 = str(lst[i + 1])
	if s2[0] != s3[0]:
		count += 1
print(count)


n = int(input())
k = str(input())
T = 1
for i in range(0, n - 1):
	t = str(input())
	if k != t:
		T += 1
	k = t
print(T)


n = int(input())
i = 0
last = ''
for k in range(n):
	inp = input()
	if inp != last:
		i += 1
	last = inp
print(i)


lis = []
num = 0
a = 0
n = int(input())
for i in range(n):
	num = input()
	lis.append(int(num))
num = 0
a = 0
for i in range(1, len(lis)):
	if lis[a] != lis[i]:
		num = num + 1
		a = lis.index(lis[i])
print(num + 1)


n = int(input())
first = int(input()[0])
no = 1
for i in range(n - 1):
	in_ = int(input()[0])
	if first != in_:
		no += 1
		first = in_
	else:
		continue
print(no)


n = int(input())
y = []
count = 0
for i in range(n):
	y.append(list(map(int, input().split())))
for i in range(n - 1):
	if y[i] != y[i + 1]:
		count += 1
print(count + 1)


n = int(input())
r = 0
for K in range(n):
	if K == 0:
		a = input()
		r = 1
		ri = a[1]
	else:
		a = input()
		if ri == a[0]:
			r += 1
		ri = a[1]
print(r)


n = int(input())
last_case = input()
groups = 1
for i in range(n - 1):
	actual_case = input()
	if actual_case != last_case:
		groups += 1
		last_case = actual_case
print(groups)


n = int(input())
groupC = 0
thing = 'yes'
for x in range(n):
	temp = input()
	if thing[-1] == temp[0]:
		groupC += 1
	elif thing == 'yes':
		groupC += 1
	thing = temp
print(groupC)


c = 0
a = []
for i in range(int(input())):
	s = input()
	a.append(s)
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		c += 1
print(c + 1)


n = int(input())
ls = list()
mx = 1
for i in range(n):
	x = input()
	ls.append(x)
for i in range(1, n):
	if ls[i] != ls[i - 1]:
		mx += 1
print(mx)


n = int(input())
list = []
for i in range(n):
	list.append(input())
q = 1
for i in range(1, n):
	if list[i] == list[i - 1]:
		pass
	else:
		q = q + 1
print(q)


n = int(input())
magnets = ''
for i in range(n):
	magnets += input()
pieces = 1 + magnets.count('00') + magnets.count('11')
print(pieces)


count = 1
k = int(input())
l = input()
for _ in range(k - 1):
	o = input()
	if o == l:
		l = o
	else:
		count += 1
		l = o
print(count)


s = int(input())
s_sample = []
for i in range(s):
	d = int(input())
	s_sample.append(d)
ans = 1
for i in range(0, len(s_sample) - 1):
	if s_sample[i] != s_sample[i + 1]:
		ans += 1
print(ans)


n = int(input())
a = list(input())
cnt = 0
for i in range(1, n):
	s = list(input())
	if a[1] != s[0]:
		a = s
	else:
		a = s
		cnt = cnt + 1
print(cnt + 1)


n = int(input())
cur = 1
count = 1
for i in range(n):
	x = int(input())
	cur1 = cur
	cur = x
	if i == 0:
		continue
	if x != cur1:
		count += 1
print(count)


n = int(input())
input_b = input()
count = 1
for i in range(n - 1):
	input_a = input()
	if input_b != input_a:
		count += 1
	input_b = input_a
print(count)


def mag(ar):
	gr = 1
	cur = ar[0][0]
	for i in ar:
		if i[0] != cur:
			gr += 1
		cur = i[0]
	print(gr)
count = int(input())
arr = []
for _ in range(0, count):
	arr.append(input())
mag(arr)


(s, k) = (0, 0)
n = input()
a = [[] * 2] * int(n)
for i in range(int(n)):
	a[i] = input()
if int(n) != 1:
	for i in range(int(n) - 1):
		if a[i][1] != a[i + 1][0]:
			if k == 1:
				continue
			else:
				s += 1
				k = 1
		elif k == 1:
			s += 1
			k = 1
		else:
			s += 2
			k = 1
			continue
else:
	s = 1
print(s)


import sys

def input():
	return sys.stdin.readline().strip()
n = int(input())
count = 0
s1 = input()
for i in range(n - 1):
	s2 = input()
	if s1[1] == s2[0]:
		count += 1
	s1 = s2
print(count + 1)


n = int(input())
k = 9
counter = 1
sum = 0

def count(n, m):
	global k
	global counter
	global sum
	if n == k:
		sum += counter
	k = m
for i in range(n):
	p = input()
	n = p[0]
	m = p[1]
	count(n, m)
sum += counter
print(sum)


n = int(input())
mag = []
for s in range(n):
	mag.append(input())
grp = 0
for i in range(len(mag) - 1):
	if mag[i] != mag[i + 1]:
		grp += 1
print(grp + 1)


from sys import stdin, stdout
inints = lambda : [int(x) for x in stdin.readline().split()]
fp = lambda s: stdout.write(str(s) + '\n')
irange = lambda x, y: range(x, y + 1)
(ans, s) = (0, '')
for _ in range(int(stdin.readline())):
	cur = stdin.readline()
	if cur != s:
		ans += 1
	s = cur
fp(ans)


from sys import stdin
from functools import reduce

def solve(p, line):
	if p[0] == line[0]:
		return p
	return (line[0], p[1] + 1)
n = int(input())
(_, ans) = reduce(solve, stdin.readlines(), ('', 0))
print(ans)


n = int(input())
a1 = input()
ans = 1
for i in range(n - 1):
	a2 = input()
	if a2 != a1:
		ans = ans + 1
		a1 = a2
print(ans)


n = int(input())
group_count = 0
(prev, cur) = (0, 0)
if n == 1:
	print(1)
else:
	for i in range(n):
		prev = cur
		cur = int(input())
		if cur != prev:
			group_count += 1
	print(group_count)


numberOfMagnets = int(input())
groups = 0
lastMagnet = ''
while numberOfMagnets > 0:
	magnet = input()
	if magnet != lastMagnet:
		groups = groups + 1
	lastMagnet = magnet
	numberOfMagnets = numberOfMagnets - 1
print(groups)


n = int(input())
c = 1
j = input()
(v, m) = (int(j[0]), int(j[1]))
b = m
for i in range(n - 1):
	j = input()
	(v, m) = (int(j[0]), int(j[1]))
	if b == v:
		c += 1
	b = m
print(c)


import sys
n = int(sys.stdin.readline())
cur = sys.stdin.readline()
g = 1
for _ in range(n - 1):
	p = sys.stdin.readline()
	if p != cur:
		g += 1
		cur = p
print(g)


quant = int(input())
dom = []
cont = 1
for i in range(quant):
	num = input()
	dom.append(num)
for i in range(quant - 1):
	if dom[i] != dom[i + 1]:
		cont += 1
print(cont)


l = []
a = 0
for i in range(int(input())):
	l.append(int(input()))
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		a += 1
print(a + 1)


n = int(input())
b = []
while n > 0:
	s = input()
	b.append(s)
	n = n - 1
count = 1
for i in range(0, len(b) - 1):
	if b[i] == '10' and b[i + 1] == '01':
		count = count + 1
	elif b[i] == '01' and b[i + 1] == '10':
		count = count + 1
	else:
		count = count
print(count)


n = int(input())
groups = 1
magnet = input().strip()
last = magnet[1]
for i in range(1, n):
	magnet = input().strip()
	actual = magnet[0]
	if actual == last:
		groups += 1
	last = magnet[1]
print(groups)


def main():
	n = int(input())
	x = 0
	count = 0
	for i in range(n):
		m = int(input())
		if m != x:
			count += 1
			x = m
	print(count)
main()


a = int(input())
r = 1
s = ''
s1 = ''
for i in range(a):
	s1 = input()
	s += s1
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		r += 1
print(r)


a = int(input())
i = 0
c = []
while i < a:
	c += [int(input())]
	i += 1
j = 0
r = 0
while j < len(c) - 1:
	if c[j] != c[j + 1]:
		r += 1
	j += 1
print(r + 1)


inputS = int(input())
t = ''
while inputS:
	t += input()
	inputS -= 1
aux = ''
f = 1
for x in t:
	if aux == x:
		f += 1
	aux = x
print(f)


a = int(input())
b = []
for i in range(a):
	c = str(input())
	b.append(c)
b = ''.join(b)
d = b.count('1001')
e = b.count('0110')
print(d + e + 1)


n = int(input())
groupCount = 1
num = input()
numCheck = num
for case in range(n - 1):
	num = input()
	if numCheck != num:
		groupCount += 1
	numCheck = num
print(groupCount)


n = int(input())
m = [input() for i in range(n)]
sum = 1
for i in range(n - 1):
	if m[i][1] == m[i + 1][0]:
		sum += 1
print(sum)


n = int(input())
a = []
t = 1
for i in range(n):
	s = input()
	a.append(s)
for i in range(n - 1):
	if a[i][1] == a[i + 1][0]:
		t += 1
	else:
		continue
print(t)


a = int(input())
i = 0
j = '00'
for k in range(a):
	b = input()
	if b != j:
		i += 1
		j = b
print(i)


n = int(input())
ans = 1
dom = []
for i in range(n):
	dom.append(int(input()))
for i in range(n):
	try:
		if dom[i] != dom[i + 1]:
			ans += 1
	except:
		print(ans)


magnets = int(input())
arrangement = ''
for i in range(magnets):
	curr = input()
	arrangement += curr
ans = 1
for i in range(1, len(arrangement)):
	if arrangement[i] == arrangement[i - 1]:
		ans += 1
print(ans)


n = int(input())
prev = 0
g = 0
while n:
	n -= 1
	m = int(input())
	if m != prev:
		g += 1
	prev = m
print(g)


a = int(input())
current_value = input()
count = 1
for i in range(a - 1):
	value = input()
	if value != current_value:
		count += 1
		current_value = value
print(count)


def Magnets():
	n = int(input().strip())
	last_pole = None
	groups = 0
	for mag in range(n):
		next_pole = input().strip()[-1]
		if last_pole is None or next_pole != last_pole:
			groups += 1
			last_pole = next_pole
	return groups
a = Magnets()
print(a)


num = int(input())
arr = []
res = 0
for x in range(0, num):
	arr.append(input())
	if arr[x] != arr[x - 1]:
		res = res + 1
print(res + 1)


n = int(input())
l = []
for x in range(n):
	l.append(input())
count = 0
for x in range(1, n):
	if l[x - 1] != l[x]:
		count += 1
count += 1
print(count)


n = int(input())
nums = []
groups = 1
for i in range(0, n):
	x = int(input())
	nums.append(x)
for j in range(1, n):
	if nums[j] != nums[j - 1]:
		groups += 1
print(groups)


n = int(input())
l = ''
a = 0
for i in range(n):
	l += input()
for j in range(len(l) - 1):
	if l[j] == l[j + 1]:
		a += 1
	else:
		pass
print(a + 1)


import sys

def rr():
	return sys.stdin.readline().rstrip()
rp = print

def print(*args, **kwargs):
	rp('DBG:# ', *args, **kwargs, file=sys.stderr)

def rri():
	return int(rr())

def rrl():
	return list(map(int, rr().split()))

def rrt():
	return tuple(map(int, rr().split()))

def rrle():
	return (line.rstrip() for line in sys.stdin.readlines())

def rrtl():
	return [tuple(map(int, l.split())) for l in rrle()]
from collections import defaultdict

def mus(d=lambda : 0):
	return defaultdict(lambda : defaultdict(d))

def dd0(d=lambda : 0):
	return defaultdict(d)

def ms(x, y, d=0):
	return [[0] * y for i in range(x)]

def ar(x, d=0):
	return [d] * x

def ppm(m, n=0, x=0, y=0):
	print('\n'.join(('\t'.join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))

def ppa(a, n):
	print('\t'.join(map(str, a[0:n])))

def ppl(a=0, x=[1]):
	x[0] = a or x[0] + 1
	print('-' + '- -' * 14 + '-# ' + str(x[0] - 2) + ' #-' + '- -' * 14 + '-')

def fltn(a):
	(i for sub in a for i in sub)

def yn(x):
	return 'YES' if x else 'NO'

def cpc(arr):
	return zip(arr, arr[1:])
from itertools import accumulate
from itertools import groupby
from itertools import permutations

def grp(x, key=None):
	return ((i, sum((1 for _ in g))) for (i, g) in groupby(x, key=key))
import math

def rnar():
	return (*rrl(), rrl())

def rn():
	return (*rrl(),)

def dpp(a, b=''):
	print('#| {} |#:^ {} ^:'.format(a, b))

def str_join(i, sep=' '):
	return sep.join(map(str, i))
MOD17 = 10 ** 9 + 7

def read():
	i = rri()
	lns = list(rrle())
	return (i, lns)

def solve(n, arr):
	x = ''.join(arr)[1:-1]
	ans = x.count('11') + x.count('00') + 1
	return ans
test_count = 1
for _ in range(test_count):
	input_data = read()
	result = solve(*input_data)
	rp(result)


count = 1
cycle = int(input())
memory = int(input())
for _ in range(cycle - 1):
	current = int(input())
	if current != memory:
		count += 1
		memory = current
print(count)


a = int(input())
x = 0
for i in range(a):
	if i == 0:
		c = input()
		continue
	b = input()
	if b != c:
		x += 1
		c = b
if a == 1:
	print(1)
	exit()
print(x + 1)


n = int(input())
prev = ''
groups = 0
for x in range(n):
	x = input()
	if x != prev:
		prev = x
		groups += 1
print(groups)


n = int(input())
liste = []
liste2 = []
gruppen = 1
for _ in range(n):
	liste.append(input())
liste2.append(liste[0])
for i in liste:
	if i != liste2[0]:
		gruppen += 1
		liste2[0] = i
print(gruppen)


n = input()
Total = 0
Text = ''
for i in range(int(n)):
	Magnet = input()
	Text += Magnet
for i in range(len(Text)):
	if i + 1 != len(Text) and Text[i] == Text[i + 1]:
		Total += 1
print(Total + 1)


n = int(input())
l = []
while n != 0:
	l.append(input())
	n -= 1
diff = sum(map(lambda pair: pair[0] != pair[1], zip(l, l[1:])))
diff += 1
print(diff)


while True:
	try:
		n = int(input())
		if 1 <= n <= 100000:
			break
	except:
		print('Wrong Input')
group = 0
lst = []
for i in range(n):
	char = int(input())
	lst.append(char)
count = 0
turn = 0
while turn != len(lst):
	try:
		for j in range(turn, len(lst)):
			turn += 1
			if lst[j] != lst[j + 1]:
				group += 1
				break
	except:
		pass
print(group + 1)


def seperateints(x):
	k = ''
	l = []
	for i in x:
		if i == ' ':
			l.append(int(k))
			k = ''
			continue
		k = k + i
	l.append(int(k))
	return l

def luckynum(x):
	for i in x:
		if i != '4' and i != '7':
			return False
	return True
n = int(input())
l = []
for i in range(n):
	l.append(input())
k = 1
for i in range(n - 1):
	if l[i][1] == l[i + 1][0]:
		k += 1
print(k)


n = int(input())
a = []
for x in range(n):
	a.append(int(input()))
l = 0
cnt = 0
for x in range(len(a)):
	if x == len(a) - 1:
		cnt += 1
	elif a[x] != a[x + 1]:
		cnt += 1
print(cnt)


a = int(input())
prev = '00'
count = 0
while a:
	p = input()
	if prev != p:
		count = count + 1
	prev = p
	a = a - 1
print(count)


mag = int(input())
(last, groups) = (0, 0)
while mag > 0:
	recent = int(input())
	if recent != last:
		groups += 1
	last = recent
	mag -= 1
print(groups)


t = int(input())
l = []
for i in range(t):
	n = input()
	l.append(n)
i = 0
l1 = []
for i in range(1, len(l)):
	if l[i - 1] != l[i]:
		l1.append(l[i])
print(len(l1) + 1)


length = int(input())
inp_list = []
for x in range(length):
	inp_list.append(int(input()))
count = 0
for item in range(len(inp_list)):
	if item == len(inp_list) - 1:
		count += 1
	elif inp_list[item] != inp_list[item + 1]:
		count += 1
print(count)


ans = 0
l = '2'
for _ in range(int(input())):
	a = input()
	if l == a[0] or l == '2':
		ans += 1
	l = a[1]
print(ans)


n = int(input())
ar = []
c = 0
for i in range(n):
	a = input()
	ar.append(a)
l = len(ar)
i = 0
while i <= l - 2:
	if ar[i] != ar[i + 1]:
		c += 1
	i += 1
print(c + 1)


import sys
data = sys.stdin.readlines()
filtered_data2 = []
for item in data:
	filtered_data2 += [int(item.strip())]
filtered_data = filtered_data2[1:]
i = 0
count = 0
while i < len(filtered_data) - 1:
	if filtered_data[i] == filtered_data[i + 1]:
		i += 1
	else:
		i += 1
		count += 1
print(count + 1)


n = int(input())
mag = 0
temp = ''
for i in range(n):
	temp2 = input()
	if mag == 0:
		mag += 1
		temp = temp2
	elif temp2 != temp:
		temp = temp2
		mag += 1
print(mag)


n = int(input())
c = 1
s = input()
n -= 1
while n:
	s1 = input()
	n -= 1
	if s1 != s:
		c = c + 1
		s = s1[:]
print(c)


n = int(input())
d1 = 0
ost = 0
for i in range(n):
	d = input()
	if d1 != d:
		ost = ost + 1
	d1 = d
print(ost)


x = int(input())
magnet = []
for i in range(x):
	magnet.append(int(input()))
c = 1
for x in range(len(magnet) - 1):
	if magnet[x] == magnet[x + 1]:
		continue
	else:
		c += 1
print(c)


magnets = int(input())
output = 1
a = input()
for i in range(magnets - 1):
	b = input()
	if a[1] == b[0]:
		output += 1
	a = b
print(output)


list1 = []
count = 1
for i in range(int(input())):
	list1.append(input())
for i in range(len(list1) - 1):
	if list1[i] == list1[i + 1]:
		continue
	else:
		count = count + 1
print(count)


n = int(input())
l = [0]
(a, b, c) = (0, 0, 0)
for (i, j) in enumerate(range(n), start=1):
	a = input()
	l.append(a) if a != l[len(l) - 1] else a
print(len(l) - 1)


n = int(input())
A = []
num = 1
for i in range(n):
	A.append(input())
for i in range(1, n):
	if A[i][0] == A[i - 1][1]:
		num += 1
print(num)


def genlis(text):
	lis = []
	for i in range(len(text) - 1):
		lis.append(text[i:i + 2])
	return lis
n = int(input())
text = ''
for i in range(n):
	text += input()
print(genlis(text).count('00') + genlis(text).count('11') + 1)


n = int(input())
p = input()
c = 1
for _ in range(1, n):
	t = input()
	if t != p:
		c += 1
		p = t
print(c)


t = int(input())
l = []
for i in range(t):
	z = input()
	l.append(z)
cnt = 0
z = 0
for i in range(1, t):
	if l[i - 1] == l[i]:
		pass
	else:
		z = z + 1
print(z + 1)


n = int(input())
i = input()
t = 1
while n - 1 > 0:
	n -= 1
	m = input()
	if m[1] == i[0]:
		t += 1
	i = m
print(t)


n = int(input())
s = ''
for i in range(n):
	s += input() + ' '
print(s.count('10 01') + s.count('01 10') + 1)


n = int(input())
count = 1
l = []
for i in range(n):
	x = input()
	l.append(x)
for j in range(len(l) - 1):
	if l[j] == l[j + 1]:
		pass
	else:
		count += 1
print(count)


anterior = ' '
counter = 0
for _ in range(int(input())):
	if _ == 0:
		anterior = input()
		counter += 1
	else:
		m = input()
		if m[0] == anterior[-1]:
			counter += 1
		anterior = m
print(counter)


import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = inin()
	count = 0
	temp2 = 0
	for i in range(n):
		temp1 = inin()
		if n == 0:
			temp2 = temp1
		else:
			if temp1 - temp2 != 0:
				count += 1
			temp2 = temp1
	print(count)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
main()


n = int(input())
li = [input() for i in range(n)]
li2 = [li[0]]
m = 0
for i in li:
	if li2[m] != i:
		li2.append(i)
		m += 1
print(len(li2))


n = int(input())
d = [input() for i in range(0, n)]
cont = 1
for i in range(0, n - 1):
	if d[i] != d[i + 1]:
		cont += 1
print(cont)


class Main:
	n = int(input())
	poles = ''
	for i in range(0, n):
		poles += input().rstrip()
	groups = 1 + poles.count('00') + poles.count('11')
	print(groups)
Main()


k = int(input())
ans = 1
prev = -1
for _ in range(k):
	m = input()
	if m[0] == prev:
		ans += 1
	prev = m[1]
print(ans)


n = int(input())
mg = list()
for _ in range(n):
	mg.append(input())
island = 0
pre = ''
for i in mg:
	if i != pre:
		island += 1
	pre = i
print(island)


numero = int(input())
inicial = None
rows = 1
for i in range(numero):
	actual = input()
	if not inicial:
		inicial = actual
	else:
		ultimo = inicial[-1]
		primero = actual[0]
		if primero == ultimo:
			rows += 1
			inicial = actual
		else:
			inicial = actual
print(rows)


n = int(input())
z = []
j = 1
for i in range(n):
	z.append(str(input()))
for i in range(n - 1):
	if z[i] != z[i + 1]:
		j += 1
print(j)


import re
n = int(input())
s = ''
for i in range(n):
	s += input()
q = re.findall('11|00', s)
print(len(q) + 1)


from itertools import groupby
alls = []
for _ in range(int(input())):
	alls.append(input())
cnt = 0
for k in groupby(alls):
	cnt += 1
print(cnt)


n = int(input())
count = 0
last = 0
for i in range(n):
	x = int(input())
	if last != x:
		count += 1
	last = x
if n == 1:
	print(1)
else:
	print(count)


a = int(input())
b = int(input())
gap = 1
for i in range(a - 1):
	c = b
	d = int(input())
	b = d
	if c != d:
		gap += 1
print(gap)


col = 0
pole = ''
for i in range(int(input())):
	p = input().strip()
	col = (col, col + 1)[p[0] != pole]
	pole = p[0]
print(col)


n = int(input())
head = None
count = 0
for i in range(n):
	x = input()
	if head == None:
		head = int(x[1])
		count += 1
	elif int(x[0]) == head:
		count += 1
		head = int(x[1])
print(count)


(p, pres, c) = (0, 0, 0)
for i in range(int(input())):
	p = pres
	pres = input()
	if p != pres:
		c += 1
print(c)


n = input()
n = int(n)
a = []
for i in range(n):
	a.append(input())
a = ''.join(a)
f = 1
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		f += 1
print(f)


n = int(input())
magnet = []
count = 1
magnet.append(input())
for i in range(1, n):
	magnet.append(input())
	if magnet[i] == '01':
		if magnet[i - 1] == '10':
			count += 1
	if magnet[i] == '10':
		if magnet[i - 1] == '01':
			count += 1
print(count)


n = int(input())
t = 1
s = input()
(a, b) = (int(s[0]), int(s[1]))
for i in range(n - 1):
	s = input()
	(c, d) = (int(s[0]), int(s[1]))
	if b == c:
		t += 1
	(a, b) = (c, d)
print(t)


k = int(input())
count = 0
last = 7
for i in range(k):
	mag = int(input())
	if mag != last:
		count += 1
		last = mag
print(count)


n = int(input())
out = 0
last = ''
for _ in range(n):
	mgnt = input()
	if mgnt != last:
		out += 1
		last = mgnt
print(out)


import math
n = int(input())
ans = 0
s1 = input()
c = s1[1]
while n > 1:
	s = input()
	if s[0] == c:
		ans = ans + 1
	c = s[1]
	n -= 1
print(ans + 1)


n = int(input())
magnets = [0] * n
for i in range(n):
	magnets[i] = str(input())
counter = 0
for i in range(1, n):
	if magnets[i - 1][1] == magnets[i][0]:
		counter += 1
print(counter + 1)


n = int(input())
previous = ''
groups = 0
for i in range(n):
	magnet = str(input())
	groups += magnet != previous
	previous = magnet
print(groups)


x = int(input())
e = 1
s = 0
n = []
while s < x:
	m = int(input())
	n.append(m)
	if s == 0:
		s += 1
		continue
	elif n[s] != n[s - 1]:
		e += 1
	s += 1
print(e)


n = int(input())
lis = []
num = 1
for i in range(n):
	tmp = input()
	lis.append(tmp)
for j in range(len(lis) - 1):
	if lis[j] != lis[j + 1]:
		num += 1
print(num)


n = int(input())
previousDirection = None
directionsChanged = 0
for times in range(n):
	direction = input()
	if previousDirection != direction:
		directionsChanged += 1
		previousDirection = direction
print(directionsChanged)


c = p = 0
for i in range(int(input())):
	s = int(input())
	c += s != p
	p = s
print(c)


n = int(input())
last = ''
cont = 0
for x in range(n):
	current = input()
	if last != current:
		cont += 1
	last = current
print(cont)


a = int(input())
c = []
j = 0
k = 1
for i in range(a):
	b = int(input())
	c.append(b)
for i in range(len(c) - 1):
	if c[i] != c[i + 1]:
		j += 1
	else:
		pass
print(j + k)


s = ''
for _ in range(int(input()) - 1):
	s += ' ' + input()
s += ' ' + input()
print(s.count('10 01') + s.count('01 10') + 1)


s = int(input())
lst = []
o = 0
for x in range(s):
	a = input()
	lst.append(a)
last = None
for i in lst:
	if i == last:
		last = i
	else:
		o += 1
		last = i
print(o)


n = int(input())
groups = 1
count = 0
while count < n:
	x = input()
	if count >= 1:
		if y != x:
			groups += 1
	y = x
	count += 1
print(groups)


i = input()
i = int(i)
it = 0
v = 1
while it < i:
	d = input()
	if it > 0:
		if d != pd:
			v = v + 1
	pd = d
	it = it + 1
print(str(v))


n = int(input())
c = 0
pre = 0
while n > 0:
	n = n - 1
	k = int(input())
	if k != pre:
		pre = k
		c = c + 1
print(c)


m = ''
for i in '*' * int(input()):
	m += input()
m = m.replace('11', '1 1').replace('00', '0 0').split()
print(len(m))


n = int(input())
x = []
c = 1
for i in range(n):
	k = int(input())
	x.append(k)
for i in range(1, len(x)):
	if x[i - 1] == x[i]:
		continue
	else:
		c += 1
print(c)


n = int(input())
m = []
groups = 1
for i in range(n):
	m.append(input())
for i in range(n):
	if not i == n - 1 and (not m[i] == m[i + 1]):
		groups += 1
print(groups)


s = input()
l = list()
count = 1
for i in range(int(s)):
	x = input()
	l.append(x)
for i in range(len(l) - 1):
	if l[i] == l[i + 1]:
		count = count
	else:
		count = count + 1
print(count)


def changeRes(prev, magnet):
	if magnet != prev:
		return 1
	return 0

def genRes(n, res, prev):
	for i in range(n):
		magnet = int(input())
		res += changeRes(prev, magnet)
		prev = magnet
	return res
n = int(input())
res = genRes(n, 0, 0)
print(res, flush=False)


list = []
num = int(input())
count = 0
i = 0
for i in range(num):
	list.append(input())
for i in range(num - 1):
	if list[i] == '10' and list[i + 1] == '01':
		count += 1
	elif list[i] == '01' and list[i + 1] == '10':
		count += 1
print(count + 1)


n = int(input())
island = 0
pm = 0
for i in range(n):
	m = int(input())
	if m != pm:
		island += 1
	pm = m
print(island)


n = int(input())
x = []
while n != 0:
	n -= 1
	x.append(input().strip())
c = 1
a = x[0]
i = 1
while i < len(x):
	if a == x[i]:
		i += 1
	else:
		a = x[i]
		i += 1
		c += 1
print(c)


n = int(input())
ans = 0
pr = ''
for i in range(n):
	r = input()
	if r != pr:
		ans += 1
	pr = r
print(ans)


n = int(input())
e = []
for i in range(n):
	x = input()
	e.append(x)
k = 0
for i in range(n - 1):
	if e[i] != e[i + 1]:
		k += 1
print(k + 1)


n = int(input())
a = 1
d = [''] * n
for i in range(n):
	d[i] = input()
for i in range(n - 1):
	if d[i] == d[i + 1]:
		a = a
	else:
		a += 1
print(a)


n = int(input())
lst = []
for i in range(n):
	x = int(input())
	lst.append(x)
temp = lst[0]
count = 1
for x in lst:
	if temp != x:
		count += 1
		temp = x
print(count)


last = '00'
n = int(input())
count = 0
for _ in range(n):
	magnet = input()
	if magnet != last:
		last = magnet
		count += 1
print(count)


n = int(input())
arr = []
cnt = 0
if n > 1:
	for i in range(n):
		a = int(input())
		arr.append(a)
	for i in range(len(arr) - 1):
		if arr[i] == arr[i + 1]:
			cnt = cnt
		else:
			cnt = cnt + 1
	print(cnt + 1)
else:
	print('1')


(ans, c) = (0, '')
for _ in range(int(input())):
	s = input()
	if s != c:
		c = s
		ans += 1
print(ans)


n = int(input())
g = 0
previous = ''
for i in range(n):
	sign = input()[0]
	if sign != previous:
		g += 1
	previous = sign
print(g)


def groups(magnets):
	groups = 1
	for i in range(len(magnets) - 1):
		if magnets[i] != magnets[i + 1]:
			groups = groups + 1
	return groups
num = int(input())
magnets = [int(input()) for i in range(num)]
print(groups(magnets))


n = int(input())
list1 = []
count = 0
for i in range(n):
	k = input()
	if list1 == []:
		list1.append(k)
	elif k not in list1:
		list1.clear()
		list1.append(k)
		count += 1
if len(list1):
	count += 1
print(count)


def pairs(n):
	if n == 1:
		a = input()
		return 1
	else:
		count = 0
	a = input()
	c = a
	while n - 1 > 0:
		b = input()
		if c[1] == b[0]:
			count += 1
			a = b
		c = b
		n -= 1
	return count + int(a[1] != b[0])
n = int(input())
print(pairs(n))


n = int(input())
q = []
c = 0
for i in range(n):
	a = input()
	q.append(a)
s = q[0]
for i in q:
	if i != s:
		c += 1
		s = i
	else:
		pass
print(c + 1)


a = int(input())
cnt = 1
pre = str(input())
for i in range(a - 1):
	s = str(input())
	if s != pre:
		cnt += 1
		pre = s
print(cnt)


import sys
input = sys.stdin.readline
ans = 0
n = int(input())
prev = None
for _ in range(n):
	x = int(input())
	if x != prev:
		ans += 1
	prev = x
print(ans)


n = int(input())
l = []
for i in range(n):
	l.append(input())
cnt = 1
for i in range(n - 1):
	if l[i] == l[i + 1]:
		continue
	else:
		cnt = cnt + 1
print(cnt)


cnt = int(input())
(gcnt, cur) = (1, input())
for i in range(1, cnt):
	tmp = input()
	if cur != tmp:
		gcnt += 1
		cur = tmp
print(gcnt)


n = int(input())
curr = int(input())
groups = 1
for i in range(1, n):
	now = int(input())
	if now == curr:
		continue
	else:
		groups += 1
		curr = now
if groups:
	print(groups)


n = int(input())
magnets = []
for _ in range(n):
	y = int(input())
	magnets.append(y)
temp = magnets[0]
ans = 1
for i in range(1, n):
	if temp != magnets[i]:
		ans += 1
		temp = magnets[i]
print(ans)


n = int(input())
x = []
cnt = 1
for _ in range(n):
	x.append(input())
for i in range(len(x) - 1):
	if x[i] == '10' and x[i + 1] == '01':
		cnt += 1
	elif x[i] == '01' and x[i + 1] == '10':
		cnt += 1
print(cnt)


n = int(input(''))
ar = []
o = ''
for i in range(0, n):
	j = str(input(''))
	o = o + j
	ar.append(j)
x = '00'
y = '11'
cx = o.count(x)
cy = o.count(y)
count = cx + cy
print(count + 1)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
gp = 1
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		gp = gp + 1
	else:
		gp = gp
print(gp)


n = int(input().strip())
s = input()
c = s[0]
res = 0
for i in range(n - 1):
	s = input()
	if c == s[1]:
		res += 1
	c = s[0]
print(res + 1)


n = int(input())
magnets = []
for i in range(n):
	magnets.append(input())
counter = 1
for i in range(1, n):
	if magnets[i] != magnets[i - 1]:
		counter += 1
print(counter)


def magnet(b):
	y = b[0]
	count = 1
	for i in b[1:]:
		if i != y:
			y = i
			count += 1
	return count
x = int(input())
a = []
for i in range(x):
	a.append(int(input()))
print(magnet(a))


n = int(input())
li = [0]
for i in range(n):
	li.append(int(input()))
cnt = 0
for i in range(1, n + 1):
	if li[i] != li[i - 1]:
		cnt += 1
print(cnt)


input_s = int(input())
before = ''
mount = 0
for i in range(input_s):
	input_l = input()
	if before != input_l:
		before = input_l
		mount += 1
print(mount)


n = int(input())
mag_old = ''
raz = 1
for i in range(n):
	mag = str(input())
	if i == 0:
		mag_old = mag
	if mag_old != mag:
		raz += 1
		mag_old = mag
print(raz)


groups = 0
previous_magnet = ''
for _ in range(int(input())):
	magnet = input()
	if magnet != previous_magnet:
		groups += 1
	previous_magnet = magnet
print(groups)


n = int(input())
r = 0
g = 0
for i in range(n):
	t = int(input())
	if t != r:
		g += 1
		r = t
print(g)


def main():
	lim = int(input())
	count = 0
	temp = ''
	for x in range(lim):
		val = input()
		if val != temp:
			count += 1
			temp = val
	print(count)
main()


n = int(input())
l = []
g = 0
for i in range(n):
	p = int(input())
	l.append(p)
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		g += 1
print(g + 1)


n = int(input())
answer = 1
str1 = input()
for i in range(1, n):
	str2 = input()
	if str1[1] == str2[0]:
		answer += 1
	str1 = str2
print(answer)


n = int(input())
s = ''
for i in range(n):
	s += input()
count = 1
prev = s[0]
for j in range(1, len(s)):
	if s[j] == prev:
		count += 1
	prev = s[j]
print(count)


n = int(input())
s = ''
for x in range(n):
	s += input()
n = n * 2
q = 1
for x in range(1, n):
	if s[x] == s[x - 1]:
		q += 1
print(q)


n = int(input())
ar = []
for i in range(n):
	ar.append(input())
x = ar[0]
c = 1
for i in range(n):
	if x != ar[i]:
		x = ar[i]
		c += 1
print(c)


no_of_magnets = int(input())
no_of_groups = 0
last_read_number = None
for i in range(no_of_magnets):
	magnet = list(input())
	if last_read_number != magnet[1]:
		no_of_groups += 1
	last_read_number = magnet[1]
print(no_of_groups)


a = [input() for i in range(int(input()))]
print(sum((a[x] != a[x + 1] for x in range(len(a) - 1))) + 1)


a = int(input())
f = [a]
n = 1
for i in range(1, a + 1):
	f.append(input())
	if f[i] != f[i - 1] and i != 1:
		n += 1
	elif i == 1:
		n = 1
print(n)


num_mags = int(input())
num_groups = 0
prev_mag_pos = None
for _ in range(num_mags):
	mag_pos = input()
	if mag_pos != prev_mag_pos:
		prev_mag_pos = mag_pos
		num_groups += 1
print(num_groups)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
group = 0
a = 0
for i in l:
	if i != a:
		group += 1
		a = i
print(group)


n = int(input())
count = 0
temp = '00'
for i in range(n):
	word = input()
	if word != temp:
		count += 1
		temp = word
print(count)


n = int(input())
counter = 0
mem_ipt = input()
for i in range(n - 1):
	ipt = input()
	if mem_ipt != ipt:
		counter += 1
	mem_ipt = ipt
print(counter + 1)


n = int(input())
lis = []
count = 0
for i in range(n):
	c = input()
	lis.append(c)
for (i, j) in zip(lis, lis[1:]):
	if i != j:
		count += 1
print(count + 1)


(n, pr, r) = (int(input()), input(), 1)
for n in range(n - 1):
	s = input()
	r += int(pr[1] == s[0])
	pr = s
print(r)


n = int(input())
groups = []
group = []
magnets = []
for mag in range(n):
	magnet = input()
	magnets.append(magnet)
c = [1 for i in range(len(magnets) - 1) if magnets[i][1] == magnets[i + 1][0]]
print(len(c) + 1)


temp = '0'
ris = 0
for i in range(0, int(input())):
	a = input()
	if a != temp:
		ris += 1
	temp = a
print(ris)


n = int(input())
count = 1
a = int(input())
c = []
for i in range(n - 1):
	b = int(input())
	if a == b:
		count += 1
	else:
		c.append(count)
		count = 1
	a = b
print(len(c) + 1)


n = int(input())
num1 = input()
m = 1
for i in range(1, n):
	num2 = input()
	if num1 != num2:
		m += 1
	num1 = num2
print(m)


def problem():
	can = int(input())
	count = 1
	anterior = input()
	for i in range(can - 1):
		nuevito = input()
		if nuevito != anterior:
			count += 1
		anterior = nuevito
	return count
print(problem())


n = int(input())
magnets = []
for x in range(n):
	magnet = input()
	magnets.append(magnet)
count = 1
for y in range(len(magnets) - 1):
	if magnets[y] != magnets[y + 1]:
		count += 1
print(count)


n = int(input())
list1 = []
for i in range(n):
	list1.append(input())
count = 1
i = 1
while i < len(list1):
	if list1[i] != list1[i - 1]:
		count += 1
	i += 1
print(count)


magnit_num = input
counter = checker = 0
for num_counter in ' ' * int(magnit_num()):
	numbers = magnit_num()
	counter += numbers != checker
	checker = numbers
print(counter)


n = int(input())
poles = []
groups = 1
for _ in range(n):
	poles.append(input())
for i in range(1, n):
	if poles[i] != poles[i - 1]:
		groups += 1
print(groups)


n = int(input())
string = []
counter = 1
for i in range(n):
	string.append(input().split())
	string[i] = ''.join(string[i])
	if i >= 1 and string[i - 1][1] == string[i][0]:
		counter = counter + 1
print(counter)


total = int(input()) - 1
count = 1
tmp = int(input())
for _ in range(total):
	current = int(input())
	if tmp != current:
		count += 1
		tmp = current
print(count)


n = int(input())
z = []
for n in range(n):
	x = input()
	z.append(x)
t = 0
for n in range(len(z) - 1):
	if z[n] != z[n + 1]:
		t += 1
	else:
		continue
print(t + 1)


n = int(input())
sum = 0
temp = input()
for i in range(n - 1):
	num = input()
	if temp != num:
		sum += 1
	temp = num
print(sum + 1)


n = int(input())
arr = []
c = 1
for j in range(n):
	data = int(input())
	arr.append(data)
for i in range(len(arr) - 1):
	if arr[i] != arr[i + 1]:
		c += 1
print(c)


n = int(input())
(l, ans) = ([], 1)
for i in ' ' * n:
	s = input()
	l.append(s)
for i in range(len(l) - 1):
	ans += 1 if l[i] != l[i + 1] else 0
print(ans)


n = int(input())
mark = ''
count = 0
for i in range(n):
	magnet = input()
	if mark == '' or mark != magnet:
		count += 1
		mark = magnet
print(count)


qtd = int(input())
(anterior, contador) = (' ', qtd)
for i in range(qtd):
	atual = int(input())
	if anterior == atual:
		contador -= 1
	anterior = atual
print(contador)


n = int(input())
l = ''
for i in range(0, n):
	a = input()
	l = l + a
p = l.count('00')
q = l.count('11')
print(int(p + q + 1))


r = 0
s = 'a'
for i in range(int(input())):
	x = input()
	if s != x:
		r = r + 1
	s = x
print(r)


n = int(input())
temp = int(input())
d1 = temp % 10
temp = temp // 10
d2 = temp % 10
count = 1
for i in range(n - 1):
	temp = int(input())
	d3 = temp % 10
	temp = temp // 10
	d4 = temp % 10
	if d1 == d4:
		count += 1
	d1 = d3
	d2 = d4
print(count)


n = int(input())
groups = 1
lst = [None] * n
magnets = 0
for magnets in range(n):
	lst[magnets] = input()
	if magnets != 0 and lst[magnets] != lst[magnets - 1]:
		groups = groups + 1
print(groups)


import sys
input = sys.stdin.readline
n = int(input())
a = []
for _ in range(n):
	a.append(input())
ans = 0
for i in range(1, n):
	if a[i] != a[i - 1]:
		ans += 1
print(ans + 1)


number_of_magnets = int(input())
_list = []
for i in range(0, number_of_magnets):
	x = input()
	_list.append(x)
number_of_groups = 1
for i in range(0, len(_list) - 1):
	if _list[i] != _list[i + 1]:
		number_of_groups = number_of_groups + 1
print(number_of_groups)


num = int(input())
answer = 0
last = 7
for i in range(num):
	mag = int(input())
	if mag != last:
		answer += 1
		last = mag
print(answer)


L = []
groups = 0
for i in range(int(input())):
	a = input()
	L.append(a)
if len(L) > 2:
	for i in range(len(L)):
		if i == len(L) - 1:
			break
		elif L[i] != L[i + 1]:
			groups += 1
	print(groups + 1)
elif len(L) == 1:
	print(1)
elif L[0] != L[1]:
	print(2)
else:
	print(1)


k = int(input())
t = []
c = 0
for i in range(0, k):
	t.append(int(input()))
kero = t[0]
for i in t[1:]:
	if kero != i:
		c += 1
	kero = i
print(c + 1)


previous = 0
now = 0
count = 0
for i in range(0, int(input())):
	now = input()
	if previous != now:
		count += 1
		previous = now
	i += 1
print(count)


n = int(input().strip())
ans = 1
l = []
for _ in range(n):
	l.append(input().strip())
prev = l[0]
for i in range(1, n):
	if l[i] != prev:
		ans += 1
		prev = l[i]
print(ans)


n = int(input())
ol = []
ol.append(int(input()))
r = 1
for x in range(n - 1):
	p = int(input())
	if p != ol[-1]:
		r += 1
		ol.append(p)
	else:
		ol.append(p)
print(r)


n = int(input())
m = 0
p = 0
for i in range(n):
	k = int(input())
	if k == m:
		m = k
	else:
		p = p + 1
		m = k
print(p)


(n, s) = (input(), '')
for i in range(int(n)):
	s += input()
(a, ind) = (0, -1)
while s.find('11', ind + 1) != -1:
	a = a + 1
	ind = s.find('11', ind + 1)
ind = -1
while s.find('00', ind + 1) != -1:
	a = a + 1
	ind = s.find('00', ind + 1)
print(a + 1)


n = int(input())
lista = []
for i in range(n):
	troco = input()
	lista.append(troco)
count = 1
for i in range(n):
	if i == n - 1:
		break
	if lista[i] != lista[i + 1]:
		count += 1
	else:
		continue
print(count)


n = int(input())
ans = 0
c = '0'
for i in range(n):
	s = input()
	if i == 0 or s[0] == c:
		ans += 1
		c = s[1]
print(ans)


n = int(input())
a = []
for i in range(n):
	b = []
	x = int(input())
	q = x // 10
	b.append(q)
	p = x % 10
	b.append(p)
	a.append(b)
k = []
t = 0
for i in range(n - 1):
	s = a[i][1] + a[i + 1][0]
	k.append(s)
for i in range(len(k)):
	if k[i] == 0 or k[i] == 2:
		t += 1
print(t + 1)


x = int(input())
e = 1
s = 0
prev = 0
if x == 1:
	print(1)
else:
	while s < x:
		m = int(input())
		if s == 0:
			s += 1
			prev = m
			continue
		elif m != prev:
			e += 1
		s += 1
		prev = m
	print(e)


n = int(input())
islands = 1
x = str(input())
before = x[1]
for a in range(n - 1):
	magnet = str(input())
	if magnet[0] == before:
		islands += 1
	before = magnet[1]
print(islands)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10, 6)))
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
t = 1
for _ in range(t):
	n = l()[0]
	A = [input() for i in range(n)]
	i = 0
	k = 0
	while i < n:
		j = i
		while j < n and A[i] == A[j]:
			j += 1
		k += 1
		i = j
	print(k)


n = int(input())
c = 0
l = []
for i in range(n):
	x = int(input())
	l.append(x)
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		c = c + 1
if len(l) == 1:
	print(1)
elif len(l) == 2:
	for i in range(len(l) - 1):
		if l[i] != l[i + 1]:
			print(2)
		else:
			print(1)
else:
	print(c + 1)


n = int(input())
b = list()
c = 1
for i in range(n):
	b.append(int(input()))
	if b[i] != b[i - 1]:
		c += 1
print(c)


import sys
m = ''.join(sys.stdin.readlines()[1:])
print(m.count('0\n0') + m.count('1\n1') + 1)


n = int(input())
res = 1
for i in range(n):
	if i == 0:
		prev = input()
	else:
		curr = input()
		if curr != prev:
			prev = curr
			res += 1
print(res)


ser = int(input())
ray = []
for i in range(ser):
	cont = input()
	ray.append(cont)
arr = ' '.join(ray)
print(arr.count('0 0') + arr.count('1 1') + 1)


magnets = []
for _ in range(int(input())):
	magnets.append(input())
count = 1
prev = magnets[0]
for i in range(1, len(magnets)):
	if prev != magnets[i]:
		count += 1
	prev = magnets[i]
print(count)


n = int(input())
mega = [input() for _ in range(n)]

def countMeganets(mylist):
	test = mylist[0]
	occur = 1
	for i in range(1, len(mega)):
		if mylist[i] != test:
			occur += 1
		test = mylist[i]
	return occur
out = countMeganets(mega)
print(out)


n = int(input())
s = []
for i in range(n):
	s.append(input())
lst = s[0]
coutn = 1
for i in s[1:]:
	if lst == i:
		continue
	else:
		lst = i
		coutn += 1
print(coutn)