from sys import stdin, stdout input = lambda: stdin.readline().rstrip() write = stdout.write def main(): N, K = map(int, input().split()) D = list(map(int, input().split())) diff = 0 d = [0] + D i = 1 while 1: if d[i] != i: j = d[i] d[i], d[j] = d[j], d[i] diff += 1 else: i += 1 if i > N: break if diff > K: write('NO\n') return ope = -(-diff // 2) if K >= ope and not (K - ope) % 2: write('YES\n') else: write('NO\n') main()