import heapq as hq N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) task = [[] for _ in range(2)] for _ in range(M): t, v = map(int, input().split()) task[t].append(v) for i in range(2): task[i].sort() state = [] seen = [0]*N Aind = sorted(list(range(N)), key=lambda x: A[x]) ind = 0 for v in task[0]: while ind < N and v >= A[Aind[ind]]: hq.heappush(state, [-B[Aind[ind]], Aind[ind]]) ind += 1 if state: w, t = hq.heappop(state) seen[t] = 1 ans = N-sum(seen) Bval = [B[i] for i in range(N) if not seen[i]] ind = 0 for i, v in enumerate(task[1]): while ind < len(Bval) and v >= Bval[ind]: ind += 1 if i < ind: ans -= 1 print(ans)