n,k=map(int,input().split()) d=list(map(lambda x: x-1, map(int,input().split()))) dif=False for i in range(n-1): if d[i] == i: continue for j in range(i+1,n): if d[j] == j or j == d[i]: continue if d[j] != i: dif = True break if dif: break cnt=0 for i in range(n): if d[i] == i: continue if d[d[i]] == i: cnt+=1 d[d[i]] = d[i] d[i] = i else: cnt+=1 if dif and k >= cnt: print("YES") else: print("YES" if cnt == k or (k>cnt and (k-cnt)&1==0) else "NO")