Hints: Passing the Ball
The process is deterministic: start at student 1 (index 0), then exactly $n$ passes. You only need to know who holds the ball after each step.
How can you avoid simulating $n$ steps if $n$ is small (e.g. at most 50)?
Answer to Hint 1: With $n \le 50$, simulating all $n$ passes is fast. So you can simply simulate: start at position $p = 0$, and for $i = 0, 1, \ldots, n-1$, record that position $p$ is visited, then set $p \leftarrow p + 1$ if $s[p]$ is R, else $p \leftarrow p - 1$.
After the loop, you also visit position $p$ one more time (the ball ends there). The answer is the number of distinct positions visited.
Answer to Hint 2: Use a set (or boolean array) to track visited positions. Before each pass, insert the current position; then update the position using $s[p]$. After the loop, insert the final position. Output the size of the set.
Answer to Hint 3: Implementation outline: read $n$ and $s$; let
vis be an empty set and p = 0. For $i = 0$ to $n-1$: add p to vis; if s[p] == 'L' then p--, else p++. Add p to vis. Print vis.size().