N, K = map(int, input().split()) D = ['dummy'] + list(map(int, input().split())) # 巡回置換の検出 peo = {i: False for i in D[1:]} ans = 0 for ix, i in enumerate(D): if ix == 0 or peo[i] or i == ix: peo[i] = True continue key = i peo[i] = True ans += 1 _next = D[i] while _next != key: peo[_next] = True ans += 1 _next = D[_next] if K >= ans and K%2 == ans%2: print('YES') else: print('NO')