def solve(): n, k = map(int, input().split()) d = [0] + list(map(int, input().split())) for i in range(1, n + 1): while d[i] != i: t = d[i] d[t], d[i] = d[i], d[t] k -= 1 if k < 0: return "NO" return "YES" if k % 2 == 0 else "NO" print(solve())