Bill picked 1/2 of the apples on his grandmothers tree. After Bill finished, Sally picked 1/3 of the apples that were left on the tree. After Sally finished, there were 40 apples left on the tree. How many apples were on the tree before they both picked apples?