Medicare will only pay for 20 days in a nursing home (in limited circumstances, it can pay partial cost of 80 additional days) while Medicaid will pay all nursing home costs.
The laws around Medicaid qualification are extensive, and there are many exceptions. Often, hospitals and nursing homes will offer to do this for you at no cost. Be careful, they do not represent you, but rather, the institution for which they work. Even with the best intentions, they often do not have the legal knowledge necessary to determine whether or not your qualification is accurate. this is where a legal professional can really be of value and often times, be able to get you benefits much sooner.