Fermi Large Area Telescope observations of Local Group galaxies: detection of M31 and search for M33