Consider a conveyor belt represented using a grid consisting of $n$ rows and $m$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left is labelled $(i,j)$. 

Every cell, except $(n,m)$, has a direction R (Right) or D (Down) assigned to it. If the cell $(i,j)$ is assigned direction R, any luggage kept on that will move to the cell $(i,j+1)$. Similarly, if the cell $(i,j)$ is assigned direction D, any luggage kept on that will move to the cell $(i+1,j)$. If at any moment, the luggage moves out of the grid, it is considered to be lost. 

There is a counter at the cell $(n,m)$ from where all luggage is picked. A conveyor belt is called functional if and only if any luggage reaches the counter regardless of which cell it is placed in initially. More formally, for every cell $(i,j)$, any luggage placed in this cell should eventually end up in the cell $(n,m)$. 

This may not hold initially; you are, however, allowed to change the directions of some cells to make the conveyor belt functional. Please determine the minimum amount of cells you have to change.

Please note that it is always possible to make any conveyor belt functional by changing the directions of some set of cells.


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10$). Description of the test cases follows.

The first line of each test case contains two integers $n, m$ ($1 \le n \le 100$, $1 \le m \le 100$)  — the number of rows and columns, respectively.

The following $n$ lines each contain $m$ characters. The $j$-th character in the $i$-th line, $a_{i,j}$ is the initial direction of the cell $(i, j)$. Please note that $a_{n,m}=$ C.


-----Output-----

For each case, output in a new line the minimum number of cells that you have to change to make the conveyor belt functional. 


-----Example-----
Input
4
3 3
RRD
DDR
RRC
1 4
DDDC
6 9
RDDDDDRRR
RRDDRRDDD
RRDRDRRDR
DDDDRDDRR
DRRDRDDDR
DDRDRRDDC
1 1
C

Output
1
3
9
0



-----Note-----

In the first case, just changing the direction of $(2,3)$ to D is enough.

You can verify that the resulting belt is functional. For example, if we place any luggage at $(2,2)$, it first moves to $(3,2)$ and then to $(3,3)$. 

In the second case, we have no option but to change the first $3$ cells from D to R making the grid equal to RRRC.

Difficulty: interview

Starter code:

Solutions:
# for _ in range(1):
for _ in range(int(input())):
    a, b = list(map(int, input().split()))
    # n = int(input())
    # arr = list(map(int, input().split()))
    # s = input()
    ans = 0
    for i in range(a - 1):
        s = input()
        if s[-1] != 'D':
            ans += 1
    s = input()
    for i in range(b - 1):
        if s[i] != 'R':
            ans += 1
    print(ans)


for _ in range(int(input())):
    n,m=map(int,input().split())
    ans=0
    for i in range(n-1):
        s=input()
        if s[-1]=='R':ans+=1
    ans+=input()[:-1].count('D')
    print(ans)

def solv():
    x,y=map(int,input().split())
    grid=[input() for n in range(x)]
    res=0
    for n in range(x-1):
        if grid[n][-1]=='R':
            res+=1
    for n in range(y-1):
        if grid[-1][n]!='R':res+=1

    print(res)

for _ in range(int(input())):
    solv()

t = int(input())
for _ in range(t):
    n,m=map(int,input().split())
    l=[]
    for i in range(n):
        l.append(input())
    ans=0
    for i in range(n-1):
        if l[i][-1]!='D':
            ans+=1
    for i in range(m-1):
        if l[-1][i]!='R':
            ans+=1
    print(ans)

def solve():
    n, m = map(int, input().split())
    lastline = []
    lastcol = []
    for _ in range(n):
        s = input()
        if _ + 1 < n:
            lastcol.append(s[-1])
        else:
            lastline = list(s)[:-1]
    print(lastcol.count('R') + lastline.count('D'))

t = int(input())
for _ in range(t):
    solve()

a=int(input())
for i in range(a):
    x,y=list(map(int,input().split()))
    ans=[]
    for i in range(x):
        s=input()
        ans.append(s[-1])
    
    print(s.count('D')+ans.count('R'))


#
#    ------------------------------------------------
#           ____          _     Generatered using
#          / ___|        | |
#         | |    __ _  __| | ___ _ __  ______ _
#         | |   / _` |/ _` |/ _ \ '_ \|_  / _` |
#         | |__| (_| | (_| |  __/ | | |/ / (_| |
#          \____\____|\____|\___|_| |_/___\____|
#
#      GNU Affero General Public License v3.0
#    ------------------------------------------------
#    Author   : prophet
#    Created  : 2020-08-09 10:41:06.753267
#    UUID     : exYAacOx6D2XBvTK
#    ------------------------------------------------
#
production = True

import sys, math, collections, bisect, itertools, heapq, decimal, random, copy, re

def input(f = 0, m = 0):

    if m > 0: return [input(f) for i in range(m)]
    else:
        l = sys.stdin.readline()[:-1]

        if f >= 10:
            u = False
            f = int(str(f)[-1])
        else: u = True

        if f == 0: p = [l]
        elif f == 1: p = list(map(int, l.split()))
        elif f == 2: p = list(map(float, l.split()))
        elif f == 3: p = list(l)
        elif f == 4: p = list(map(int, list(l)))
        elif f == 5: p = l.split()

        return p if u else p[0]

def out(l, f = 0, n = True):

    if f == 0: p = str(l)
    elif f == 1: p = " ".join(map(str, l))
    elif f == 2: p = "\n".join(map(str, l))
    elif f == 3: p = "".join(map(str, l))

    print(p, end = "\n" if n else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)

def mapl(i, f = 0):

    if f == 0: return list(map(int, i))
    elif f == 1: return list(map(str, i))
    elif f == 2: return list(map(list, i))

#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#


def solve():

    n, m = input(1)
    a = input(3, n)

    t = 0

    for i in a[-1]:
        if i == "D":
            t += 1

    for i in range(n):
        if a[i][-1] == "R":
            t += 1

    out(t)

    log()
    return


for i in range(input(11)): solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#


t = int(input())

for _ in range(t):
    n, m = list(map(int, input().split()))
    a = []
    for __ in range(n):
        a.append(list(input()))

    o = 0
    for i in range(n):
        if a[i][-1] == 'R': o += 1

    for i in range(m):
        if a[-1][i] == 'D': o += 1

    print(o)


from collections import *
from sys import stdin,stderr
def rl():
    return [int(w) for w in stdin.readline().split()]

t, = rl()
for _ in range(t):
    n, m = rl()
    a = [stdin.readline().rstrip() for _ in range(n)]
    r = 0
    for c in a[-1]:
        if c == 'D':
            r += 1
    for l in a:
        if l[-1] == 'R':
            r += 1
    print(r)