import sys from collections import defaultdict, deque from math import gcd, inf, factorial from bisect import bisect_left, bisect_right, insort_left, insort_right from heapq import heapify, heappop, heappush from decimal import Decimal from copy import deepcopy from pprint import pprint MOD = 998244353 input = lambda : sys.stdin.readline().rstrip() LIP = lambda : list(map(int, input().split())) LSP = lambda : list(input().split()) TIP = lambda : tuple(map(int, input().split())) TSP = lambda : tuple(input().split()) SIP = lambda : set(map(int, input().split())) SSP = lambda : set(input().split()) yes = lambda : print("Yes") no = lambda : print("No") dame = lambda : print(-1) mint = lambda n: (n + MOD) % MOD #---------------------------------------------- def main(): N, K = LIP() A = LIP() B = LIP() sortedA = sorted(A) sortedB = sorted(B) if sortedA != sortedB: return no() l = max(0, N - K + 1) r = min(N, K - 1) for i in range(l, r): if A[i] != B[i]: return no() return yes() if __name__ == '__main__': main()