# -*- coding: utf-8 -*- N,K = map(int, input().split()) D = list(map(int, input().split())) c1 = 0 c2 = 0 for i,d in zip(range(1,N+1), D): if i!=d: if i!=D[d-1]: c1 += 1 else: c2 += 1 total = c1 + c2//2 if (K-total)%2==0: print('YES') else: print('NO')