Denote by $ S$ the set of all positive integers. Find all functions $ f: S \rightarrow S$ such that
\[ f (f^2(m) \plus{} 2f^2(n)) \equal{} m^2 \plus{} 2 n^2\]
for all $ m,n \in S$.

[i]Bulgaria[/i]
1. **Assertion and Injectivity:**
   Let \( A(m, n) \) be the assertion of the given functional equation:
   \[
   f(f^2(m) + 2f^2(n)) = m^2 + 2n^2
   \]
   To show that \( f \) is injective, assume \( f(a) = f(b) \). Then, from \( A(m, a) \) and \( A(m, b) \), we have:
   \[
   f(f^2(m) + 2f^2(a)) = m^2 + 2a^2
   \]
   \[
   f(f^2(m) + 2f^2(b)) = m^2 + 2b^2
   \]
   Since \( f(a) = f(b) \), it follows that \( f^2(a) = f^2(b) \). Therefore:
   \[
   m^2 + 2a^2 = m^2 + 2b^2 \implies 2a^2 = 2b^2 \implies a = b
   \]
   Thus, \( f \) is injective.

2. **Initial Values:**
   Assume \( f(1) = a \). Using \( A(1, 1) \), we get:
   \[
   f(f^2(1) + 2f^2(1)) = 1^2 + 2 \cdot 1^2 = 3
   \]
   Therefore:
   \[
   f(3a^2) = 3
   \]

3. **Finding Specific Values:**
   Consider the pairs \((m_1, n_1)\) and \((m_2, n_2)\) such that \( m_1^2 + 2n_1^2 = m_2^2 + 2n_2^2 \). For example, \((5, 1)\) and \((3, 3)\) are such pairs:
   \[
   5^2 + 2 \cdot 1^2 = 3^2 + 2 \cdot 3^2 = 27
   \]
   Using \( A(5a^2, a^2) \), \( A(3a^2, 3a^2) \), \( A(a^2, 4a^2) \), and \( A(5a^2, 2a^2) \), we get:
   \[
   f(5a^2 + 2a^2) = 5^2 + 2 \cdot 1^2 = 27 \implies f(7a^2) = 27
   \]
   \[
   f(3a^2 + 2 \cdot 3a^2) = 3^2 + 2 \cdot 3^2 = 27 \implies f(9a^2) = 27
   \]
   \[
   f(a^2 + 2 \cdot 4a^2) = 1^2 + 2 \cdot 4^2 = 33 \implies f(9a^2) = 33
   \]
   \[
   f(5a^2 + 2 \cdot 2a^2) = 5^2 + 2 \cdot 2^2 = 33 \implies f(9a^2) = 33
   \]
   This implies \( f(9a^2) = 27 \) and \( f(9a^2) = 33 \), which is a contradiction unless \( a = 1 \).

4. **General Form:**
   Since \( f(1) = 1 \), we can generalize this for all \( n \). Assume \( f(na^2) = n \). Then:
   \[
   f(f^2(m) + 2f^2(n)) = m^2 + 2n^2
   \]
   implies:
   \[
   f(m^2 + 2n^2) = m^2 + 2n^2
   \]
   Therefore, \( f(n) = n \) for all \( n \).

Conclusion:
\[
\boxed{f(n) = n}
\]