import heapq n,m=map(int,input().split()) hq=[];hq2=[] for i,j in zip(list(map(int,input().split())),list(map(int,input().split()))): heapq.heappush(hq,(i,j)) x,y=[],[] for i in range(m): a,b=map(int,input().split()) c=x if a else y c.append(b) y.sort();x.sort() for i in y: while hq and hq[0][0]<=i: a,b=heapq.heappop(hq) heapq.heappush(hq2,-b) if hq2: heapq.heappop(hq2);n-=1 hq3=[] while hq: a,b=heapq.heappop(hq);heapq.heappush(hq3,b) while hq2: heapq.heappush(hq3,-heapq.heappop(hq2)) for i in x: if hq3 and hq3[0]<=i: n-=1;heapq.heappop(hq3) print(n)