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: interview

Starter code:

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

#Magnets

n = int(input())

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

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


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 = []
b = ''
ot = 0
for i in range(n):
    t = input()
    if t != b:
        ot += 1
    b = t
print(ot)

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

n = int(input())
sum = 0
magnet = 0
for i in range(n):
    magneti = input()
    if magneti != magnet:
        sum += 1
        magnet = magneti
print(sum)

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 )

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

#have last digit of previous entry
#for every line in the input check the first digit
#if digits are same
# increment count

def solve():
    prev_last = -1
    count = 0
    n = int(input())
    for _ in range(n):
        first,last = input()
        if prev_last == -1 or prev_last == first:
            count += 1
        prev_last = last
    return count

print(solve())


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)                
       


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
                


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

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)

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())
cnt = 1
x, y, a, b = 0,0,0,0
for i in range(n):
    x, y = input()
    if i == 0:
        a, b = x, y
    else:
        if a != x:
            cnt += 1
        a, b = x, y
print(cnt)

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())
count = 1
a = []
for i in range(n):
    a.append(int(input()))
for i in range(1, n):
    if a[i] != a[i - 1]:
        count += 1
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)

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 )


__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 = []
ans = 1
for i in range(n):
    num = int(input())
    a.append(num)
for i in range(1, n):
    if a[i] != a[i-1]:
        ans += 1
print(ans)


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

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