It's a counter similar to wish credits in refines. Free draws and scrolls both count to that counter. If you max out the counter, you get a rare. If you are lucky with rng and draw the rare early (something like 1% chance per scroll), the counter immediately reset to zero. So if you got lucky and got your rare at 40 scrolls, your next gauranteed rare will be at 100 scrolls; and not 60 or 120.
Edo is slightly different, in the sense that the counter is only 30 or 40.