answer for second problem