Magnets

题意翻译

众所周知,两个磁铁同极相斥,异极相吸。现在有 $n$ 条条形磁铁(不能掉转顺序),每回摆出 $1$ 个磁铁摆在桌上,能够相吸的磁铁会连成一块,问摆完 $n$ 条磁铁后桌上磁铁的组数。 第一行读入一个整数 $n$ ,随后 $n$ 行,每行两个 $01$ 串表示磁铁的状态( $1$ 代表正极,$0$ 代表负极)。 输出仅一行,代表磁铁的组数。 实在看不懂可以看以下对样例 $1$ 解释: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF344A/5ad7b55de90b4c95ae686ce6e02cbb9c5dff4d4e.png) 在摆放完前 $3$ 条磁铁后,它们相吸成一组,摆放第四个磁铁后会被前面的一组排斥,成为单独的一组,摆放第五个磁铁后会被第四个磁铁排斥,与第四个磁铁分离,摆放第六个磁铁后会与前面的磁铁相吸,与第五个磁铁形成一组。至此,共有 $3$ 组磁铁($1,2,3$ 号为一组,$4$ 号为一组, $5,6$ 号为一组)。

题目描述

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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF344A/5ad7b55de90b4c95ae686ce6e02cbb9c5dff4d4e.png)Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.

输入输出格式

输入格式


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.

输出格式


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

输入输出样例

输入样例 #1

6
10
10
10
01
10
10

输出样例 #1

3

输入样例 #2

4
01
01
10
10

输出样例 #2

2

说明

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.