import Data.List (findIndex) swap :: [a] -> Int -> Int -> [a] swap xs a b = fst t1 ++ [xs !! pred j] ++ fst t2 ++ [xs !! pred i] ++ t3 where i = min a b j = max a b t1 = splitAt (pred i) xs t2 = splitAt (pred $ j - i) (tail . snd $ t1) t3 = tail . snd $ t2 rep :: Integral a => [Int] -> [Int] -> Int -> a -> a rep ds idxs i cnt | i > length ds = cnt | ds !! (pred i) == i = rep ds idxs (succ i) cnt | otherwise = rep (swap ds i (idxs !! (pred i))) (swap idxs (ds !! pred i) (ds !! pred (idxs !! pred i))) (succ i) (succ cnt) solve :: Integral a => Int -> a -> [Int] -> Bool solve n k ds | cnt <= k && even (k - cnt) = True | otherwise = False where Just idxs = fmap (map succ) . sequenceA $ (\x -> findIndex (== x)) <$> [1..n] <*> pure ds cnt = rep ds idxs 1 0 main = do [n, k] <- map read . words <$> getLine ds <- map read . words <$> getLine putStrLn $ case solve n k ds of True -> "YES" False -> "NO"