4. Find the number of triples of natural numbers $m, n, k$, which are solutions to the equation $m+$ $\sqrt{n+\sqrt{k}}=2023$. (20 points)
Solution: For the left side to be an integer, the numbers $k$ and $n+\sqrt{k}$ must be perfect squares, and since $n+\sqrt{k} \geq 2$, it follows that $\sqrt{n+\sqrt{k}} \geq 2$ and thus $m \leq 2021$. Since $1 \leq m \leq$ 2021, $\sqrt{n+\sqrt{k}}$ can take any value from 2 to 2022 - this value uniquely determines the number $m$. Let $k=x^{2}$ and $n+\sqrt{k}=y^{2}$, where $1 \leq x \leq y^{2}-1$ and $2 \leq y \leq 2022$, then the number $n$ is uniquely determined, specifically $n=y^{2}-x$. Therefore, we need to count the number of 
admissible pairs $(x, y)$. There are a total of $\left(2^{2}-1\right)+\ldots+\left(2022^{2}-1\right)=1^{2}+2^{2}+\ldots+2022^{2}-2022$. The formula for the sum of the squares of the first $n$ natural numbers is known:

$$
1^{2}+2^{2}+\ldots+n^{2}=\frac{n(n+1)(2 n+1)}{6}
$$

Applying this formula, we get $1^{2}+2^{2}+\ldots+2022^{2}-2022=\frac{2022 \cdot 2023 \cdot 4045}{6}-2022=$ 27575680773.

## Answer: 27575680773