mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) seen = [0] * (N+1) M = 0 for i in range(1, N+1): if seen[i]: continue p = A[i] cnt = 0 seen[i] = 1 while True: cnt += 1 if p != i: seen[p] = 1 p = A[p] else: break M += cnt - 1 if M > K: print("NO") else: if (K - M) & 1: print("NO") else: print("YES") if __name__ == '__main__': main()