import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] class BIT: def __init__(self, n): self.n = n self.data = [0]*(n+1) def to_sum(self, i): s = 0 while i > 0: s += self.data[i] i -= (i & -i) return s def add(self, i, x): while i <= self.n: self.data[i] += x i += (i & -i) def get(self, i, j): return self.to_sum(j)-self.to_sum(i-1) def main(): N,K = map(int,input().split()) D = list(map(int,input().split())) Tree = BIT(N) inversion_number = 0 for i in range(N): #自分以下で既に出てきた数字(i.e.左側にある数字)を引く。 inversion_number += i - Tree.to_sum(D[i]) #BITは1-indexだがDも1-index Tree.add(D[i],1) #出てきた数字を記録 mn = 0 A = [d-1 for d in D] loc = [-1]*N for i,a in enumerate(A): loc[a] = i for i in range(N): if A[i] == i: continue j = loc[A[i]] A[i],A[j] = A[j],A[i] loc[i] = A[i] loc[j] = A[j] mn += 1 #print(mn) #一致させるのに必要な最小回数にKが足りない。 if mn > K: print('NO') #回数が足りる場合には転倒数の偶奇でよい。 elif (inversion_number - K)%2 == 0: print('YES') else: print('NO') if __name__ == '__main__': main()