n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
type0 = []
type1 = []
for _ in range(m):
    t, c = map(int, input().split())
    if t == 0:
        type0.append(c)
    else:
        type1.append(c)

# Sort products by A and keep original indices
sorted_A = sorted([(A[i], i) for i in range(n)], key=lambda x: x[0])
# Sort products by B and keep original indices
sorted_B = sorted([(B[i], i) for i in range(n)], key=lambda x: x[0])

sold = [False] * n
count = 0

# Process type0 buyers (sorted descending)
type0.sort(reverse=True)
ptr_a = n - 1  # Start from the highest A
for c in type0:
    while ptr_a >= 0:
        a_val, idx = sorted_A[ptr_a]
        if a_val <= c and not sold[idx]:
            sold[idx] = True
            count += 1
            ptr_a -= 1
            break
        else:
            ptr_a -= 1
    else:
        break  # No more products

# Process type1 buyers (sorted descending)
type1.sort(reverse=True)
ptr_b = n - 1  # Start from the highest B
for c in type1:
    while ptr_b >= 0:
        b_val, idx = sorted_B[ptr_b]
        if b_val <= c and not sold[idx]:
            sold[idx] = True
            count += 1
            ptr_b -= 1
            break
        else:
            ptr_b -= 1
    else:
        break  # No more products

print(n - count)