For any positive integer \(n\), let \[ f(n) = \begin{cases} \log_8{n}, & \text{if }\log_8{n}\text{ is rational,} \\ 0, & \text{otherwise.} \end{cases} \] Find the value of \(\sum_{n = 1}^{1997}{f(n)}\). The original answer is in \(\frac{k}{m}\) format, please give the value of k + m.

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