Number of pixels in the image IMG is size(IMG,1) * size(IMG,2)
Editing the LSB of each pixel is something that I will leave for you to figure out. LSB steganography is a common class assignment that for an experienced programmer is usually only a few lines long, but I have seen students stuck on the assignment for literally more than 6 months. It would be unfair to the other students to give you the easy answer when so many students struggle for long times with the assignment.
For whatever reason, it has turned out to be an assignment that separates those who "get" computer programming from those those who do not "get" computer programming, so I have found it best not to interfere in this "rite of passage".