# Toby and his game SOLUTION TOBY

Page Contents

### Toby and his game SOLUTION TOBY

Toby has discovered a game to engage himself.The game is this way:

You are in an organize framework at first at (0,0) and you are given a grouping of steps which lead to your destination.The steps are given as headings: ‘U’ ,’D’ , ‘L’ and ‘R’ for up, down, left and right respectively.If you are at position (x,y) at that point:

U:move to (x,y+1)

D:move to (x,y-1)

L:move to (x-1,y)

R:move to (x+1,y)

The arrangement is given as a string ‘s’ of characters where si (1≤i≤N) is one of the bearing character as referenced above.An case of a grouping of steps is: UULRUDR

The objective as per this string is (1,2).

You need to eliminate most extreme number of characters from the string with the end goal that the subsequent string prompts a similar objective as in the past.

For instance in the model above we can eliminate characters at positions 1,3,4,6 and the subsequent way will be UUR which will prompt a similar objective i.e (1,2).so we diminished the quantity of steps by 4,and this is our score. You have to get greatest score.

Information:

First line will contain T, number of testcases. At that point the testcases follow.

First line of each testcase contains a solitary whole number N,size of string.

Second line of testcase contains a string s of size N.

Yield:

For each testcase, yield a solitary line containing the most extreme score conceivable.

Limitations

1≤T≤1000

1≤N≤105

Test Input:

ULUDLLU

RUUR

LRLR

Test Output:

Clarification:

experiment 1: The last objective in the wake of moving as per the grouping is (- 3,2).

One path is to eliminate characters at positions 3,4 and the subsequent string will be ULLLU objective despite everything remains (- 3,2).

experiment 2: No character can be taken out for this situation.

THANKS FOR JOINING THE LIVE
SOLUTIONS WILL BE SHARED HERE SOON