N, K = map(int, input().split())
D = ['dummy'] + list(map(int, input().split()))

# 巡回置換の検出
peo = dict()
ans = 0
for ix, i in enumerate(D):
    if ix == 0 or (i in peo) or i == ix:
        continue 
    key = i
    _next = D[i]
    while _next != key:
        peo[_next] = True
        _next = D[_next]
        ans += 1


if K >= ans and K%2 == ans%2:
    print('YES')
else:
    print('NO')