The second sentence seems to be a joke. It is telling you that since an octopus has three hearts and nine brains if you are brainy (meaning if you have a lot of brains) and heartbroken (meaning you have more than one piece of a heart) then that makes you the same as the octopus. Sharing the same traits with an octopus should then make you less lonely.
I hope that helps.