from bisect import bisect_left N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(M)] S = list(set(A+B)) S.sort() K = len(S) task = [[[] for _ in range(2)] for _ in range(K)] for i, a in enumerate(A): ind = bisect_left(S, a) task[ind][0].append(i) for i, b in enumerate(A): ind = bisect_left(S, b) task[ind][1].append(i) seen = [0]*N C.sort(key=lambda x: x[1]) ind_task = 0 X = [[] for _ in range(2)] for t, v in C: while ind_task < K and v >= S[ind_task]: for i in range(2): for s in task[ind_task][i]: X[i].append(s) ind_task += 1 while X[t]: ind = X[t].pop() if not seen[ind]: seen[ind] = 1 break print(N-sum(seen))