solve second problem