I need help with an anydice function.
I'm looking for a modified Roll and Keep type of mechanic, where if you have more dice that roll the max result than you are keeping, each discarded max result adds +1 to the total.
Example: if you were rolling 6d10 and keeping two (equivalent to HIGHEST 2 of 6d10 in anydice), and you rolled 10, 10, 10, 8, 3, and 1, your total would be 21--that's 20 for the two 10s you kept, and +1 for the 10 you couldn't keep.
Example 2: if you were rolling 5d6 drop 2 (equivalent to HIGHEST 3 of 5d6 in anydice), and rolled 6, 6, 6, 6, and 6, your result would be 20.
Maybe I don't know how to word what I am looking for correctly, but I have not been able to find any answers to this question when searching around online.
Thanks in advance.