#C10235. Final Position on the Number Line
Final Position on the Number Line
Final Position on the Number Line
You are given a string consisting solely of the characters R
and L
. Starting at position 0 on the number line, each R
moves you one unit to the right (i.e., adds 1), and each L
moves you one unit to the left (i.e., subtracts 1). Formally, if you denote the final position as \(P\), then
\(P = \sum_{i=1}^{n} d_i\),
where \(d_i = 1\) if the i-th character is R
and \(d_i = -1\) if it is L
.
Your task is to read the input string from stdin, compute the final position after processing all characters, and output the result to stdout.
inputFormat
The input consists of a single line containing a non-empty string of characters. Each character in the string is either R
or L
.
outputFormat
Output a single integer representing the final position on the number line after applying all the moves described by the input string.
## sampleRRRR
4