#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int power(long long int b, long long int e, long long int m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long int power(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
long long int inv[600000 + 5], fac_inv[600000 + 5], fac[600000 + 5];
void initialize() {
  long long int i;
  inv[1] = 1;
  for (i = 2; i <= 600000; i++)
    inv[i] = (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353;
  fac[0] = fac[1] = 1;
  for (i = 2; i <= 600000; i++) fac[i] = i * fac[i - 1] % 998244353;
  fac_inv[0] = fac_inv[1] = 1;
  for (i = 2; i <= 600000; i++)
    fac_inv[i] = inv[i] * fac_inv[i - 1] % 998244353;
}
long long int ncr(long long int n, long long int r) {
  if (n < r) return 0;
  return (fac[n] * fac_inv[r] % 998244353) * fac_inv[n - r] % 998244353;
}
long long int bin_ser(long long int f, long long int l, long long int N,
                      long long int k) {
  if (l == f) {
    return l;
  }
  long long int mid = (f + l) / 2, ans, i = 1;
  ans = mid;
  while (mid / power(k, i)) {
    ans += mid / power(k, i);
    i++;
  }
  if (ans > N) {
    ans = bin_ser(f, mid, N, k);
  } else if (ans < N) {
    if (l - f == 1) {
      return l;
    } else {
      ans = bin_ser(mid + 1, l, N, k);
    }
  } else {
    return mid;
  }
  return ans;
}
set<pair<long long int, long long int> >::iterator it;
map<long long int, long long int> dp, ex;
vector<long long int> v;
void bins(long long int x) {
  long long int l = 0, h = v.size() - 1;
  long long int m = (l + h) / 2;
  while (l < h) {
    m = (l + h) / 2;
    if (v[m] == x) {
      v.insert(v.begin() + m, x);
      return;
    } else if (v[m] < x) {
      l = m + 1;
    } else {
      h = m - 1;
    }
  }
  if (v[l] < x & v[l + 1] >= x) {
    v.insert(v.begin() + l + 1, x);
  } else if (v[l] >= x) {
    v.insert(v.begin() + l, x);
  }
}
void solve() {
  long long int x, y;
  cin >> x >> y;
  string a;
  long long int ans = 0;
  for (long long int i = 0; i < x - 1; i++) {
    cin >> a;
    ans += (a[y - 1] == 'R');
  }
  cin >> a;
  ans += count(a.begin(), a.end(), 'D');
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
