Instanton counting and the chiral ring relations in supersymmetric gauge theories