Problems > Robot on a Line

Robot on a Line

Difficulty: 800 2000 ms 128 MB

implementation

A robot starts at position 0 on a number line and follows a command string: L moves it one step left, R one step right. Where does it end?

Input: one line with the command string S.

Output: the final position.

Constraints:

  • 1 ≤ |S| ≤ 105

Sample Tests

Input 1
RRL
Output 1
1
Input 2
LLL
Output 2
-3

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.