#!/usr/bin/env python3 def judge(n, k, ds): ps = [ds[i] for i in range(n)] c = 0 for i in range(n): if ds[i] != i: j = ps[i] ds[i], ds[j] = ds[j], ds[i] ps[ds[i]] = i ps[ds[j]] = j c += 1 return c <= k and (c + k) % 2 == 0 def main(): n, k = (int(x) for x in input().split()) ds = [int(x) - 1 for x in input().split()] print("YES" if judge(n, k, ds) else "NO") if __name__ == '__main__': main()