You are playing Risk and someone with a large army is attacking one of your countries which also has a large army. (These are large to avoid the awkward cases where you start losing access to some of your dice.) However, instead of rolling at the same time, your attacker has jumped the gun and accidentally rolled xyr* dice before you, instead of at the same time. This gives you a bit of an edge over normal since you can choose to roll either 1 or 2 defending dice having already seen the attacking dice.
I made a spreadsheet to calculate what you should do which you can play around with here. Since only the top two attacking dice matter I've only put two input boxes (yellow) and it outputs whether you should choose 1 or 2 dice. I haven't optimised anything so, for example, make sure that the top yellow box is the higher (or joint higher) dice.
To get straight to the results you can find them below. A simple way to remember it (which I can't imagine would be a very useful thing to do: go spend your memory on something useful for game theory like all of the 2 letter words for scrabble instead) is that if you see a 3 on either of your opponents dice then you should be using both dice.
*Once again a gender neutral pronoun. Xyr meaning the equivilent of his/her without being plural.