#include <bits/stdc++.h>
using namespace std;
int t, n, m;
char a[101][101];
int main() {
  cin >> t;
  while (t--) {
    int ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        cin >> a[i][j];
        if (i == n && a[i][j] == 'D') ans++;
        if (j == m && a[i][j] == 'R') ans++;
      }
    cout << ans << endl;
  }
  return 0;
}
