Do you mean the MINIMUM amout of bags from which the counterfeits could be isolated? Because the maximum number of bags is 25. I could just walk in there, tell the king that the counterfeits are somewhere in the 25 bags over in the corner, and then leave.

If you want the minimum, I have it down to 2 bags in some cases, and no bags in other cases. I used a variation on my answer from the previous riddle.

1. 6 vs 6 with 13 to the side. This will give you either an equal result, in which case the ones to the side are the bad ones (go to 2A) or it will give you an unequal result in which case on of the two lots on the scale is bad and the one to the side is good (go to 2B).

2A. Take the 8 of the bad ones and measure against 8 of the remaining good ones. If this is equal that means the last 5 bags are counterfeit. - go to 3A. If this is inequal, you now know whether the counterfeits are lighter or heavier and you know they are in the 8 bad bags on the scale. (Go to 3B).

3A. Take 4 good bags and 4 bad bags. If they are equal, the last bag is counterfeit. If they are not equal, you now know if the counterfeit bag is lighter or heavier than the rest. (Go to 4A).

3B. Put 3 bad bags on each side of the scale and 2 bad bags aside. If the bags on the scale are equal, you know the last two are counterfeit. Go to 4B. If they are unequal, go to 4C.

4A. From the last 4 bags, put one on each side of the scale and two to the side. You know if the counterfeit is lighter or heavier, so if the scale is inequal, you know your counterfeit bag. If the scale is equal, the counterfeit is is one of the two remaining bags.

4B. From your two remaining bad bags, put one bad bag on the scale and measure against a good bag. From this weighing you will know which of the two bags is counterfeit.

4C. Take the three bad bags and put one on each side of the scale and one to the side. You know if the counterfeit is lighter or heavier, so you know which bag on the scale is counterfeit if the scale is inequal, otherwise the one to the side is the counterfeit.