Determination of the pion and kaon structure functions