N, K = map(int,input().split()) D = [ x for x in map(int,input().split())] num = 0 for i in range(len(D)): tmp = D[i] if tmp == i+1: continue else: D[i] = D[tmp-1] D[tmp-1] = tmp num += 1 diff = K - num if diff >= 0 and diff % 2 == 0: print("YES") else: print("NO")