What is the average of all positive integers that have three digits when written in base $5$, but two digits when written in base $8$? Write your answer in base $10$.

Let's think step by step and output the final answer within \boxed{}.
user