  We report on our search for the optical counterparts of two ultraluminous
X-ray pulsars with known orbital periods, M82 X-2 and NGC 5907 X-1, in new and
archival HST observations, in an effort to characterize the donor stars in
these systems. We detect five near-infrared sources consistent with the
position of M82 X-2 that are too bright to be single stars. We also detect
seven sources in the WFC3/UVIS F336W image whose photometry matches that of
10-15 M$_\odot$ stars turning off the main sequence. Such stars have densities
consistent with the properties of the donor star of M82 X-2 as inferred from
X-ray timing analysis, although it is also possible that the donor is a lower
mass star below our detection limit or that there is a significant contribution
from the accretion disc to the optical emission. We detect three candidate
counterparts to NGC 5907 X-1 in the near-infrared. All of these are too bright
to be the donor star of the ULX, which based on its orbital period is a red
giant. The high background at the location of NGC 5907 X-1 precludes us from
detecting this expected donor star. The recently discovered NGC 5907 ULX-2 also
falls within the field of view of the near-infrared imaging; we detect four
sources in the error circle, with photometry that matches AGB stars. The star
suggested to be the counterpart of NGC 5907 ULX-2 by Pintore et al. (2018)
falls outside our 2-$\sigma$ error circle.
