Newborn constipation

MJ

My daughter is 17 days old and struggling with bad constipation. I feel like she is in so much pain. When she poops it’s yellow and grainy. She is formula fed, she was a month early and we are trying to help her gain weight. Any help or suggestions? We do the bicycle legs and put her legs in the square position.