function countStones(stones, n) {
for (let i = 0; i < n; i++) {
const freqs = new Map();
stones.forEach(([stone, freq]) => {
blink(stone).forEach((newStone) => {
freqs.set(newStone, (freqs.get(newStone) || 0) + freq);
});
});
stones = [...freqs.entries()];
}
return d3.sum(stones, (d) => d[1]);
}