You can qualify for Medicare if you are a United States citizen or a permanent legal resident living in the U.S. for at least five years. You are qualified to receive Social Security by having worked at least 40 quarters (10 years) in your lifetime.
If you did not work the adequate quarters, but your spouse did, you may be able to qualify for Medicare using their work credits, as long as they are at the eligibility age for Social Security benefits (62).