Yes the number pins matters. The pins determins what sort of slot it will fit into on a motherbaord as these have to be exactly the same.
Now p8h61 supports ddr3 memory which is what uses the 240 pin modules.
Download the list at the bottom and it shows what has been tested compatible by asus with that motherboard: https://www.asus.com/Motherboards/P8H61MX/HelpDesk_QVL/
Many other models of memory will work but asus garantees compatability with those on the list.
FYI would recommend you ask first and buy second. Near poitnless to purchase something AND THEN ask if it will work.