At a horse show, there are both people and horses in the ring. Maria counted 22 heads and 64 legs. How many horses and people are in the ring?