All Submissions


A BOT is at point(0,0) of coordinate axes and facing towards positive X.
It gets an instruction string (S) which contains of letters 'F','L' and 'R'.

if S[i] is F: Bot moves forward 1 unit in the facing direction.
if S[i] is R: Bot turns right.
if S[i] is L: Bot turns left.

The operator who was responsible for feeding the instruction string into the Bot,made an error.
He made the error at exactly one place in the actual string
eg: If The actual instruction string was FF, the operator could have fed it as LF,RF,FR,FL .
You are supposed to tell that how many different end locations are possible for the BOT.
Length of the String <=10000

Input:
Input will conatain many test cases(<=100) .Read Till EOF.
Each Test case will conatain a string containg only of letters F,L and R.

Output:
For each test case,Output number of different end locations for the Bot.

Sample Input:

FF
FFLRF
FFLFLFRLF
FFLLFLFLFFLFFR


Sample output:

3
8
13
18

Problem Setter : Jayant Mukherji

Source: http://www.spoj.com/problems/WRONG/


Languages: AWK,Bash,Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Python3,Ruby,Text

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0