The accountant charged $35 for the first hour of work and $23 for each hour after that. He earned a total of $127. How many hours did he work?