from sys import stdin input=lambda :stdin.readline()[:-1] n,m=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) t0=[] t1=[] for i in range(m): t,c=map(int,input().split()) if t: t1.append(c) else: t0.append(c) t0.sort() t1.sort() from heapq import heappop, heappush ab=[] for i in range(n): ab.append([a[i],b[i]]) ab.sort() idx=0 hq=[] ans=0 for c in t0: while idx!=n and ab[idx][0]<=c: heappush(hq,-ab[idx][1]) idx+=1 if hq: ans+=1 heappop(hq) while idx!=n: heappush(hq,-ab[i][1]) idx+=1 hq2=[] for i in hq: heappush(hq2,-i) for c in t1: if hq2 and hq2[0]<=c: heappop(hq2) ans+=1 print(n-ans)