The pain you are describing sounds like fissures, a small tear in the skin. You probably want to get some ointment that has lidocaine in it to reduce the pain. The grain-like substance has to be from something you ate.
Thanks Celia, will have to see Dr. if it persists.
If you go to the dr, please let us know what the outcome is. Kinda sounds like something you ate to me - maybe a whole wheat grain or something. And if you are having multiple bm's, that could cause pain.