#import pdb; pdb.set_trace() import sys import math def main(): (n, k) = map(int, raw_input().split()) d = map(int, raw_input().split()) count = 0 j = 0 for i in range(n): tmpd = d[j] if tmpd - 1 != j: tmpe = d[tmpd - 1] d[tmpd - 1] = tmpd d[j] = tmpe count += 1 else: j += 1 while k > count: count += 2 if k == count: print "YES" else: print "NO" if __name__ == '__main__': main()