There is certainly some structure in your example, so maybe also to other ideals that you have in mind?
The first thing I would do is to make experiments and try to guess a formula. Here is Macaulay2 code for this:
R = QQ[X,S]
f = (a,b,d) -> ideal (X^a - S^b, sum flatten entries basis (d,R))
The first line creates a ring, and the second line defines a function that, given a,b,d, returns the ideal in your example. Now we can fix a=b=2, say and look at this ideal as a function of d. I would suggest to compute its primary decomposition directly. This gives you a lot of information. If you do that, you'll observe that the ideal contains a power of S if and only if d is even and that the power seems to be d+1. Now you can try to prove this from the generators... If a=b=3, then it seems to contain a power of S if and only if d leaves remainder 0 or 1 mod 3. The power seems to be d+2 in this case.
I hope you can see how useful experimentation is for such questions. Maybe after doing this kind of practice for a couple of ideals you can come up with an intuition what properties of $f$ and $g$ you want to look at.