Counting gauge invariant operators in supersymmetric theories using Hilbert series