It's true the 351M/400 looks like the 400M (both part of the "335 series" family of engines, along w/the 351C). Even the designation "351M/400" confuses the issue, IMO.
I've read the dampers are different (400M thicker), but w/o the two to compare, that's no help w/o the actual dimension- which I don't currently have. The only real difference is in the cranks- the 351 has a 3.5" stroke, the 400 has a 4" stroke (biggest Ford stroke).
There will be a VIN designation for what engine came in the truck. In 1977, this would be "H" if a 351M/400, "S" if the 400M.
Check your VIN Number:
Fourth character is the Engine Code
A - 6 cyl - 240cid - 1BBL carb - 1973-74
B - 6 cyl - 300 cid - 1BBL carb - 1973-80
G - V8 - 302cid - 2BBL carb - 1973-80
H - V8 - 351cid - 2BBL carb - 1973-80
Y - V8 - 360cid - 2BBL carb - 1973-76
H - V8 - 390cid - 2BBL carb - 1973-76
M - V8 - 390cid - 4BBL carb - 1974-78
S - V8 - 400cid - 2BBL carb - 1977-80
J - V8 - 460cid - 4BBL carb - 1973-80
The block and head casting numbers are supposed to be the same, and deck height, heads, intake are all identical for all practical purposes, it seems.
One improvement can be made fairly easily, that is to change the timing set to a non retarded aftermarket timing set. From around '73 or so, the cam timing was retarded to meet emissions requirements. If it looks like the front of the engine has been apart, this may have been done already.
Changing the timing set and adding the 4-barrel intake/carb with cold air feeding the carb and a set of headers w/dual exhaust that include low restriction mufflers and an "X" or "H" connection between the two sides located after the collector but before the mufflers, are the most beneficial mods that can be easily and relatively cheaply made. A good tuneup will help, too.
Swapping cams is another option, but the heads come as a non adjustable valve train that have to be modified to make them adjustable in order to use an aftermarket cam. Things start to get spendy at and beyond this stage.
Good INFO SITE.
Some more INFO.
VIN number decoder
. Entering your VIN will tell you about your truck.