n = int(input())
xs = ''
for _ in range(n):
    xs = xs + input()
r = 0
for i in range(1, n):
    if xs[i] == xs[i - 1]:
        r += 1
print(r)

c10f917900230d792369b74cf74b7494f69bbd8f
<mask token>

<mask token>
for _ in range(n):
    xs = xs + input()
<mask token>
for i in range(1, n):
    if xs[i] == xs[i - 1]:
        r += 1
print(r)

n = int(input())
xs = ''
for _ in range(n):
    xs = xs + input()
r = 0
for i in range(1, n):
    if xs[i] == xs[i - 1]:
        r += 1
print(r)
