#ds801. 梦幻布丁
梦幻布丁
Dream Pudding
Problem Source
HNOI2009
Problem Description
There are puddings placed in a row, and operations are performed. Each operation turns all the puddings of one colour into another colour, and then asks how many colour segments there are in total at the moment.
For example, four puddings with colours form colour segments in total.
Input Format
The first line contains two integers , the number of puddings and the number of operations.
The second line contains integers , the colour of the -th pudding.
The following lines describe one operation each. Each line begins with an integer indicating the operation type:
- If , then two integers follow, meaning change all puddings of colour into colour . It is guaranteed that , and may equal .
- If , it means a query.
Output Format
For each operation of the second type (a query), output in order how many colour segments there are at that moment.
Sample Input
4 3
1 2 2 1
2
1 2 1
2
Sample Output
3
1