If you consider how big the "Alta California" claim the United States took as its prize following the Mexican-American War, that would remove a few stars. The Oregon territory was divided into three states at least.
Whats possible:
California (OTL California, Nevada, Utah, W. New Mexico, Arizona)
Oregon (OTL Oregon, Washington, Idaho)
Texas (OTL Texas, E. New Mexico, E. Colorado)
The Nebraska territory doesn't have to be divided into its respective states, tho I think a state built of both North and South Dakota is possible, called Dakotah.
I don't quite know if you want to extend this to both Hawaii and Alaska, since they are not "Western states" in the historical sense. Without them it becomes a little easier to work one's way down to 40.