Given a finite string $S$ of symbols $X$ and $O$, we write $@(S)$ for the number of $X$'s in $S$ minus the number of $O$'s. (For example, $@(XOOXOOX) =-1$.) We call a string $S$ [b]balanced[/b] if every substring $T$ of (consecutive symbols) $S$ has the property $-2 \leq @(T) \leq 2$. (Thus $XOOXOOX$ is not balanced since it contains the sub-string $OOXOO$ whose $@$-value is $-3$.) Find, with proof, the number of balanced strings of length $n$.
To find the number of balanced strings of length \( n \), we need to ensure that every substring \( T \) of \( S \) satisfies \( -2 \leq @(T) \leq 2 \). We will use the face values of \( X \) and \( O \) to help us analyze the problem.

1. **Define Face Values:**
   - Let the face value of \( X \) be \( 1 \).
   - Let the face value of \( O \) be \( -1 \).

2. **Sum of Face Values:**
   - Let \( S_k \) be the sum of the face values of the first \( k \) elements of the string \( S \).
   - A string is balanced if and only if for any two indices \( l \) and \( m \), \( S_l - S_m \in \{-2, -1, 0, 1, 2\} \).

3. **Difference Between Consecutive Elements:**
   - Clearly, \( S_k \) and \( S_{k+1} \) can differ only by \( 1 \) (since the face values are either \( 1 \) or \( -1 \)).
   - Therefore, if we write a sequence for \( S_i \), say \( 1, 0, -1, 0, -1, 0, 1 \), we are actually referring to the sequence \( XOOXOXX \), which satisfies the given conditions.

4. **Balanced Sequence Construction:**
   - To construct a balanced sequence of \( S_i \), we need to ensure that the sequence remains within the bounds of \(\{-2, -1, 0, 1, 2\}\).

5. **Rules for Writing Balanced Sequences:**
   - Assume that the first character of the balanced string is \( X \). At the end, we will double our answer to account for the strings starting with \( O \).
   - Each \( S_i \) string thus starts with \( 1 \).

6. **Possible Characters in \( S_i \):**
   - Note that in each string of \( S_i \), there can only appear \( 3 \) different characters.
   - These may be \(\{-1, 0, 1\}\) or \(\{0, 1, 2\}\). The value \( -2 \) cannot appear as \( 1 \) exists in the string.

7. **Counting Balanced Strings:**
   - Consider each of the above two cases and count the number of possible strings in each case. The easiest way is to find manually for trivial cases, then prove by induction.

Let's start with small values of \( n \) and build up:

- For \( n = 1 \):
  - The possible strings are \( X \) and \( O \).
  - Total: \( 2 \).

- For \( n = 2 \):
  - The possible strings are \( XX, XO, OX, OO \).
  - Total: \( 4 \).

- For \( n = 3 \):
  - The possible strings are \( XXX, XXO, XOX, XOO, OXX, OXO, OOX, OOO \).
  - Total: \( 8 \).

We observe that for each additional character, the number of balanced strings doubles. This is because each balanced string of length \( n \) can be extended by either \( X \) or \( O \) while maintaining the balance condition.

By induction, we can prove that the number of balanced strings of length \( n \) is \( 2^n \).

The final answer is \( \boxed{ 2^n } \).