Swap Permutation
题号:NC237150
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There is a permutation p_1, p_2... p_n (it is guaranteed that 1,2...,n occurs exactly once in permutation p)

Now we need to do exactly k operations, select two different positions i, j in each operation, and then swap the values of p_i and p_j.

After k operations, we construct an undirected graph with n points labeled 1,2,...n

In the initial state, there are no edges in the graph. then, for each i from 1 to n, we connect an undirected edge between i and p_i.

Find the minimum number of connected components.

输入描述:


The first line contains 2 interger - the length of permutation, and the number of operations.
The Second Line contains n integers - the permutation p

输出描述:

For each test case, print a single integer, the minimum number of connected components.
示例1

输入

复制
4 2
1 2 3 4

输出

复制
2

说明

 In test case 1, We can get the optimal solution by swap(p_1,p_2) and swap(p_3,p_4).
示例2

输入

复制
5 1
2 1 4 3 5

输出

复制
2