#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double PI = 2 * acos(0.0);
const double EPS = 1e-8;
const int INF = 1000000000;
int m, n, ans, cr, ca;
char s[5000][5001], ss[5000][5001];
int f[5000][5000];
vector<short> du[5000], dd[5000], dl[5000], dr[5000];
int fun(int r, int c) {
  int rr = r, cc = c;
  int res = 0;
  while (true) {
    cr = rr;
    ca = cc;
    char k = s[rr][cc];
    ++res;
    s[rr][cc] = '.';
    if (k == 'U') {
      while (rr >= 0 && s[rr][cc] == '.') rr -= du[rr][cc];
      du[cr][ca] = cr - rr;
      if (rr < 0) return res;
    } else if (k == 'D') {
      while (rr < m && s[rr][cc] == '.') rr += dd[rr][cc];
      dd[cr][ca] = rr - cr;
      if (rr >= m) return res;
    } else if (k == 'L') {
      while (cc >= 0 && s[rr][cc] == '.') cc -= dl[rr][cc];
      dl[cr][ca] = ca - cc;
      if (cc < 0) return res;
    } else if (k == 'R') {
      while (cc < n && s[rr][cc] == '.') cc += dr[rr][cc];
      dr[cr][ca] = cc - ca;
      if (cc >= n) return res;
    };
  };
  return 0;
};
int main() {
  scanf("%d%d\n", &m, &n);
  for (int ii = 0; ii < m; ++ii) {
    du[ii].assign(1, n);
    dl[ii].assign(1, n);
    dd[ii].assign(1, n);
    dr[ii].assign(1, n);
  };
  for (int i = 0; i < m; ++i) gets(ss[i]);
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) f[i][j] = -1;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j)
      if (ss[i][j] != '.') {
        for (int ii = 0; ii < m; ++ii) {
          du[ii].assign(n, 1);
          dl[ii].assign(n, 1);
          dd[ii].assign(n, 1);
          dr[ii].assign(n, 1);
        };
        for (int ii = 0; ii < m; ++ii)
          for (int jj = 0; jj < n; ++jj) {
            s[ii][jj] = ss[ii][jj];
          };
        f[i][j] = fun(i, j);
        ans = max(ans, f[i][j]);
      };
  int cnt = 0;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j)
      if (f[i][j] == ans) ++cnt;
  cout << ans << " " << cnt;
  return 0;
};
