#include <bits/stdc++.h>
using namespace std;
long long n, m, y, z, now, ans, dp[5005], l[5005], r[5005], u[5005], d[5005],
    lh[5005], rh[5005], uh[5005], dh[5005];
char a[5005], c;
void dsu(long long x) {
  if (a[x] == 'U' && !uh[x]) {
    return;
  }
  if (a[x] == 'D' && !dh[x]) {
    return;
  }
  if (a[x] == 'R' && !rh[x]) {
    return;
  }
  if (a[x] == 'L' && !lh[x]) {
    return;
  }
  ans++;
  y = lh[x], z = rh[x];
  rh[y] = z, lh[z] = y;
  y = uh[x], z = dh[x];
  dh[y] = z, uh[z] = y;
  if (a[x] == 'U') {
    dsu(uh[x]);
  } else if (a[x] == 'R') {
    dsu(rh[x]);
  } else if (a[x] == 'L') {
    dsu(lh[x]);
  } else if (a[x] == 'D') {
    dsu(dh[x]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c;
      a[(i - 1) * m + j] = c;
    }
  }
  for (int i = 1; i <= m; i++) {
    now = 0;
    for (int j = 1; j <= n; j++) {
      if (a[(j - 1) * m + i] == '.') {
        continue;
      }
      d[now] = (j - 1) * m + i;
      u[(j - 1) * m + i] = now;
      now = (j - 1) * m + i;
    }
    d[now] = 0;
  }
  for (int i = 1; i <= n; i++) {
    now = 0;
    for (int j = 1; j <= m; j++) {
      if (a[(i - 1) * m + j] == '.') {
        continue;
      }
      r[now] = (i - 1) * m + j;
      l[(i - 1) * m + j] = now;
      now = (i - 1) * m + j;
    }
    r[now] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int q = 1; q <= m; q++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= m; k++) {
          lh[(j - 1) * m + k] = l[(j - 1) * m + k];
          rh[(j - 1) * m + k] = r[(j - 1) * m + k];
          uh[(j - 1) * m + k] = u[(j - 1) * m + k];
          dh[(j - 1) * m + k] = d[(j - 1) * m + k];
        }
      }
      ans = 1;
      if (a[(i - 1) * m + q] != '.') {
        dsu((i - 1) * m + q);
        dp[ans]++;
      }
    }
  }
  for (int i = 5000; i >= 1; i--) {
    if (dp[i]) {
      cout << i << " " << dp[i] << '\n';
      return 0;
    }
  }
}
