#K3061. Unique Positions Visited

    ID: 24875 Type: Default 1000ms 256MiB

Unique Positions Visited

Unique Positions Visited

You are given an integer n and a string moves of length n consisting only of the characters L and R. The moves indicate steps from an initial position 0 on a number line. A move of L decreases the current position by 1, whereas a move of R increases it by 1.

Your task is to compute the number of unique positions visited during the sequence of moves, including the starting position.

Formally, if you denote the initial position as \( p_0 = 0 \) and subsequent positions as \( p_i \), where \( p_i = p_{i-1} - 1 \) if the \( i \)-th move is L or \( p_i = p_{i-1} + 1 \) if it is R, then you need to determine the cardinality of the set \( \{p_0, p_1, \dots, p_n\} \).

inputFormat

The input is provided via standard input and consists of two lines:

  1. The first line contains an integer n — the length of the moves string.
  2. The second line contains a string moves of length n composed solely of the characters L and R.

outputFormat

Output a single integer on standard output — the number of unique positions visited at least once.

## sample
8
LLRRLRRL
4