# Read number of heroes and challenges H, C = map(int, input().split()) heroes = [] for _ in range(H): strength, weakness = input().split() heroes.append((int(strength), weakness)) challenges = [] for _ in range(C): difficulty, ctype = input().split() challenges.append((int(difficulty), ctype)) # For each hero, count conquerable challenges for strength, weakness in heroes: count = 0 for difficulty, ctype in challenges: if strength >= difficulty and ctype != weakness: count += 1 print(count)