import sys input = sys.stdin.readline N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) D = [] for i in range(N): D.append([A[i], B[i], 0]) L = [[-1], [-1]] for i in range(M): T, C = map(int, input().split()) L[T].append(C) D.sort(reverse=True) L[0].sort() L[1].sort() for i in range(N): if D[i][0] <= L[0][-1]: D[i][2] += 1 L[0].pop() for i in range(N): D[i][0], D[i][1] = D[i][1], D[i][0] D.sort(reverse=True) for i in range(N): if D[i][0] <= L[1][-1]: D[i][2] += 1 L[1].pop() from collections import * ans = 0 cnt = 0 ind = deque() for i in range(N): if D[i][2] == 2: ind.append(i) elif D[i][2] == 1: continue else: if ind: D[ind.popleft()][2] -= 1 D[i][2] += 1 for i in range(N): D[i][0], D[i][1] = D[i][1], D[i][0] D.sort(reverse=True) ans = 0 cnt = 0 for i in range(N): if D[i][2] == 2: ans += 1 cnt += 1 elif D[i][2] == 1: ans += 1 else: if cnt: ans += 1 cnt -= 1 print(N - ans)