#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int mod = 1e9 + 7;
int main() {
  int t, n, m;
  char a[105][105];
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int tot = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] == 'D' && i + 1 == n) tot++;
        if (a[i][j] == 'R' && j + 1 == m) tot++;
      }
    }
    cout << tot << '\n';
  }
  return 0;
}
