def check(L,M): B =list() B.append(M[0]) M.remove(M[0]) while B[0] != L[B[-1]]: B.append(L[B[-1]]) M.remove(B[-1]) return M N,K = map(int,input().split()) l = {i+1:int(j) for i,j in enumerate(input().split())} m = [i+1 for i in range(N)] #print(l) #print(m) for i in range(1,N+1): if l[i] == i: m.remove(i) a = len(m) while len(m) != 0: a -= 1 m = check(l,m) if K -a >= 0 and (K-a)%2 == 0: print("YES") else: print("NO")