From dynamics on surfaces to rational points on curves