#include <bits/stdc++.h>
using namespace std;
const int MAX_HW = 5000;
const char dcs[] = "RULD";
const int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0, 1};
int dcmap[128];
char s[MAX_HW + 4], fs0[MAX_HW], fs1[MAX_HW];
short nbs0[MAX_HW][4], nbs1[MAX_HW][4];
inline bool inside(int x, int y, int w, int h) {
  return x >= 0 && x < w && y >= 0 && y < h;
}
inline void remcell(short (*nbs)[4], int p) {
  for (int di0 = 0; di0 < 4; di0++) {
    int di1 = (di0 ^ 2), p0 = nbs[p][di0];
    if (p0 >= 0) nbs[p0][di1] = nbs[p][di1];
  }
}
int main() {
  for (int i = 0; i < 4; i++) dcmap[dcs[i]] = i;
  dcmap['.'] = -1;
  int h, w;
  scanf("%d%d", &h, &w);
  int hw = h * w;
  int dps[4] = {1, -w, -1, w};
  for (int y = 0, p = 0; y < h; y++) {
    scanf("%s", s);
    for (int x = 0; x < w; x++, p++) {
      fs0[p] = dcmap[s[x]];
      for (int di = 0; di < 4; di++)
        nbs0[p][di] = inside(x + dxs[di], y + dys[di], w, h) ? p + dps[di] : -1;
    }
  }
  for (int p = 0; p < hw; p++)
    if (fs0[p] < 0) remcell(nbs0, p);
  int maxr = 0, maxc = 0;
  for (int st = 0; st < hw; st++)
    if (fs0[st] >= 0) {
      int p = st, r = 0;
      memcpy(fs1, fs0, sizeof(fs0));
      memcpy(nbs1, nbs0, sizeof(nbs0));
      while (p >= 0) {
        int ndi = fs1[p];
        fs1[p] = -1;
        remcell(nbs1, p);
        r++;
        p = nbs1[p][ndi];
      }
      if (maxr < r)
        maxr = r, maxc = 1;
      else if (maxr == r)
        maxc++;
    }
  printf("%d %d\n", maxr, maxc);
  return 0;
}
