n, k = map(int, input().split()) d = [int(i)-1 for i in input().split()] for i in range(n): while d[i] != i: d[d[i]], d[i] = d[i], d[d[i]] k -= 1 print(['NO', 'YES'][k == 0 or k % 2 == 0])