n, k = [ int(v) for v in input().split() ] number_list = [ (int(v)-1) for v in input().split() ] change_list= [] for i in range(n): if number_list[i] == i: number_list[i] = -1 elif number_list[i] == -1: pass else: temp_list = [number_list[i]] next_i = number_list[i] number_list[i] = -1 while next_i not in [i,-1] : temp_list.append(number_list[next_i]) now_i = next_i next_i = number_list[next_i] number_list[now_i] = -1 change_list.append(temp_list) change_list = [len(change_list[i])-1 for i in range(len(change_list))] if k >= sum(change_list) and (k - sum(change_list)) % 2 == 0: print("YES") else: print("NO")