import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long K = sc.nextLong(); int [] D = new int [N+1]; for(int i=1; i<=N; i++){ D[i] = sc.nextInt(); } int c=0; for(int i=1; i<=N; i++){ if(i!=D[i]){ int tmp = D[i]; D[i] = D[tmp]; D[tmp] = tmp; c++; } } boolean b = true; if(c>K||K-c==1)b = false; if(b){ System.out.println("YES"); }else{ System.out.println("NO"); } } }