#include <bits/stdc++.h>
using namespace std;
struct point {
  point *l, *r, *u, *d;
} p[5010], q[5010], *ii, *jj;
int i, j, n, m;
int num = 0;
char s[5010];
inline void rm(point* pp) {
  if (pp->l) {
    pp->l->r = pp->r;
  }
  if (pp->r) {
    pp->r->l = pp->l;
  }
  if (pp->d) {
    pp->d->u = pp->u;
  }
  if (pp->u) {
    pp->u->d = pp->d;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf(" %c", &s[num]);
      if (i) {
        assert(num >= m);
        p[num].u = &p[num - m];
        p[num - m].d = &p[num];
      }
      if (j) {
        p[num].l = &p[num - 1];
        p[num - 1].r = &p[num];
      }
      num++;
    }
  }
  for (i = 0; i < num; i++) {
    if (s[i] == '.') {
      rm(&p[i]);
    }
  }
  int ans = 0, ansnum = 0, now;
  memcpy(q, p, sizeof(p));
  for (i = 0; i < num; i++) {
    if (s[i] == '.') {
      continue;
    }
    if (i) memcpy(p, q, sizeof(q));
    ii = &p[i];
    now = 0;
    while (ii) {
      now++;
      rm(ii);
      switch (s[ii - p]) {
        case 'D':
          ii = ii->d;
          break;
        case 'U':
          ii = ii->u;
          break;
        case 'L':
          ii = ii->l;
          break;
        case 'R':
          ii = ii->r;
          break;
        default:
          assert(0);
      }
    }
    if (now > ans) {
      ans = now;
      ansnum = 1;
    } else if (now == ans) {
      ansnum++;
    }
  }
  printf("%d %d\n", ans, ansnum);
  return 0;
}
