import sys def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 A = list(map(int, input[ptr:ptr+N])) ptr += N B = list(map(int, input[ptr:ptr+N])) ptr += N regular = [] mma = [] for _ in range(M): T = int(input[ptr]) ptr += 1 C = int(input[ptr]) ptr += 1 if T == 0: regular.append(C) else: mma.append(C) def max_sell(group_prices, customers): group_prices.sort() customers.sort() m = len(customers) n = len(group_prices) i = j = count = 0 while i < n and j < m: if group_prices[i] <= customers[j]: count += 1 i += 1 j += 1 else: j += 1 return count reg_prices = A mma_prices = B r_count = max_sell(reg_prices, regular) m_count = max_sell(mma_prices, mma) total = r_count + m_count min_left = N - total print(min_left) if __name__ == "__main__": main()