n,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) if a== b: print('Yes') exit() if k == n and a == b[:-1] or a == b: print('Yes') exit() if k >= n : print('No') exit() if sorted(a) == sorted(b): print('Yes') exit() print('No')