In general, there's no straightforward way in LR to search for photos with exactly two keywords and no others. LR's support for exact keyword match is pretty poor.
One way to do it:
1. In the Library Filter bar's Metadadata browser, add two Keyword columns.
2. In the first column, select the first person keyword.
3. In the second column, select the second person keyword. Now, the only photos showing are those with both keywords (using exact match), but those photos may contain other keywords.
4. Select all the photos and put them in the Quick Collection.
5. Select the Quick Collection.
6. Remove the second column from the Metadata browser.
7. In the first column select all the keywords by clicking the first keyword and shift-clicking the last keyword.
8. Deselect the two person keywords in the Keyword column by Cmd/Ctrl-clicking them. Now only those photos in the Quick Collection that contain keywords other than the two person keywords are displayed.
9. Select all the displayed photos and remove them from the Quick Collection. The Quick Collection now contains photos with exactly the two person keywords and no other keywords.
----
If you do these kinds of queries frequently, consider the
Any Filter plugin to do this, e.g.
View attachment 16732
For example, if your person keywords are under a top-level keyword People, and you want to find those photos with exactly two People keywords but perhaps other non-People keywords (e.g. Place keywords), it would take more steps doing it manually with LR built-in features. But you could do with it a saved Any Filter.