I am assuming you have no access to an impact wrench, so what I did in a case like this on my XR500 was, I put a sproket on the countershaft,then put a large pipe wrench on the sproket, and then you can either put the handle in a vice or do what i did(position the motor towards a wall or something so that the wrench handle will hit and thwrench will hold steady), Hope this helps.
ATC350X,ATC70,1991 RM 250,XR500,TM400,TS400,Foreman400 4X4,Polaris 425 Magnum,ATC 90, 1982 175,1973 Honda Trail 90,1980 CR80,1981 CR80,