Where valleys run from the edge of the roof to a ridge, trim the flashing to fit under the corresponding side of the ridge shingles. Pull the nails at that side of the ridge shingles to install the flashing, and re-nail the ridge after the flashing is nailed in place.