[This program should do what you want:](https://anydice.com/program/32538) ``` function: push REROLL:s HITS:n SIXES:n { NEW_HITS: [count {5, 6} in REROLL] NEW_SIXES: [count 6 in REROLL] if SIXES + NEW_SIXES >= 2 { result: 3 } if NEW_HITS >= 1 { result: [lowest of HITS + NEW_HITS and 2] } result: [lowest of HITS - 1 and 2] } function: vaesen INITIAL:s { HITS: [count {5, 6} in INITIAL] SIXES: [count 6 in INITIAL] BLANKS: [count {2, 3, 4} in INITIAL] if SIXES >= 2 { result: 3 } if HITS >= 1 & BLANKS >= 1 { result: [push BLANKSd6 HITS SIXES] } result: [lowest of HITS and 2] } loop C over {1..6} { output [vaesen Cd6] named "[C]d" } ``` Note that there are some subtleties: * There is no reason to reroll if you rolled two sixes initially. * You can't reroll if there are no blanks. You might also explore strategic pushing. For what it's worth, I have a [more advanced calculator](https://highdiceroller.github.io/icepool/apps/year_zero_engine.html) for [the SRD version](https://freeleaguepublishing.com/wp-content/uploads/2023/03/YZE-Standard-Reference-Document.pdf) of the Year Zero Engine, though *Vaesen* does not use this version.