Jerry wants to get a new gym membership. One membership costs $40 and $10 for each class he attends. The other membership costs $170 and he can attend an unlimited amount of classes. How many classes must Jerry attend for both memberships to cost the same?