Since \( \mathbf{a} \) and \( \mathbf{b} \) are unit vectors and the angle between them is \( \frac{\pi}{3} \), we know that:
\[
\mathbf{a} \cdot \mathbf{b} = \cos\left(\frac{\pi}{3}\right) = \frac{1}{2}.
\]
For the vectors \( \lambda \mathbf{a} + 2 \mathbf{b} \) and \( 3 \mathbf{a} - \lambda \mathbf{b} \) to be perpendicular, their dot product must be zero:
\[
(\lambda \mathbf{a} + 2 \mathbf{b}) \cdot (3 \mathbf{a} - \lambda \mathbf{b}) = 0.
\]
Expanding this:
\[
\lambda \cdot 3 + 2 \cdot (-\lambda) \cdot \frac{1}{2} = 0.
\]
Solving this gives \( \lambda = 0 \).
Therefore, there is only 1 value of \( \lambda \).