When water cools from 27 to 5 degrees, heat is given off which can be calculated using the heat capacity of water.
That same heat is absorbed (conservation of energy, so set up an equation) by the melting ice which after melting turns to water and has its temp raised from 0 to 5 deg. The heat of fusion for ice melting is known. The heat capacity of water that comes from the ice melt as it is raised to 5 degrees is known. The only unknown to solve for is the grams of ice.