It's quite hard because you need to count existing records in B and then apply conditional logic if their number less or more than value Y from table A. Then you will find record(s) to check a box and you cannot apply repeated action because you used conditional logic. And there is no action to substract from list of values to know what record must be added;.
You may use workarounds using a bit scripting to retrieve single ID from 'Find Records' result, or to get a last value from list.
But I think you should use linking and it's features. When you add " x1, x2, x5" into linked field, it will link to respective records in linked table, and if such records absent, create them. So, if somebody add, for example, x8, you just put result to linked field (" x1, x2, x5, x8"), and fourth record will be auto-created and linked. And if somebody remove, for example, x2, you put " x1, x5, x8" to linked field. Record x2 will remain but became unlinked.
I think, that provide main functionality, and 2 more automations needed to support: when record created in B, fill it with respective data (taken from linked record in A). When record in B loses its link, mark it as 'cancelled'
But that may be implemented in different other ways.