#include <bits/stdc++.h>
using namespace std;
const int inf(1010101010);
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, 1, 0, -1};
int h, w;
vector<vector<int> > a;
vector<vector<int> > rowpred, rowsucc;
vector<vector<int> > colpred, colsucc;
int ii[5005], jj[5005];
inline void dorm(int y, int x) {
  int rpred(rowpred[y][x]), rsucc(rowsucc[y][x]);
  if (rpred != -1) rowsucc[y][rpred] = rsucc;
  if (rsucc != -1) rowpred[y][rsucc] = rpred;
  int cpred(colpred[x][y]), csucc(colsucc[x][y]);
  if (cpred != -1) colsucc[x][cpred] = csucc;
  if (csucc != -1) colpred[x][csucc] = cpred;
}
int sim(int y0, int x0) {
  for (int i(0); i < (h); i++) {
    int nj(0);
    for (int j(0); j < (w); j++)
      if (a[i][j] >= 0) jj[nj++] = j;
    if (nj == 0) continue;
    rowpred[i][jj[0]] = rowsucc[i][jj[nj - 1]] = -1;
    for (int k(0); k < (nj - 1); k++)
      rowpred[i][jj[k + 1]] = jj[k], rowsucc[i][jj[k]] = jj[k + 1];
  }
  for (int j(0); j < (w); j++) {
    int ni(0);
    for (int i(0); i < (h); i++)
      if (a[i][j] >= 0) ii[ni++] = i;
    if (ni == 0) continue;
    colpred[j][ii[0]] = colsucc[j][ii[ni - 1]] = -1;
    for (int k(0); k < (ni - 1); k++)
      colpred[j][ii[k + 1]] = ii[k], colsucc[j][ii[k]] = ii[k + 1];
  }
  int cnt(0);
  for (int y(y0), x(x0);;) {
    cnt++;
    int d(a[y][x]);
    int yy, xx;
    if (d == 0) {
      if (colpred[x][y] == -1) goto klaar;
      yy = colpred[x][y], xx = x;
    } else if (d == 2) {
      if (colsucc[x][y] == -1) goto klaar;
      yy = colsucc[x][y], xx = x;
    } else if (d == 3) {
      if (rowpred[y][x] == -1) goto klaar;
      yy = y, xx = rowpred[y][x];
    } else if (d == 1) {
      if (rowsucc[y][x] == -1) goto klaar;
      yy = y, xx = rowsucc[y][x];
    }
    dorm(y, x);
    y = yy, x = xx;
  }
klaar:;
  return cnt;
}
int main() {
  cin >> h >> w;
  a.resize(h);
  for (int i(0); i < (h); i++) {
    a[i].resize(w);
    string s;
    cin >> s;
    for (int j(0); j < (w); j++) {
      char c(s[j]);
      int& r(a[i][j]);
      if (c == 'U')
        r = 0;
      else if (c == 'R')
        r = 1;
      else if (c == 'D')
        r = 2;
      else if (c == 'L')
        r = 3;
      else
        r = -1;
    }
  }
  colpred = vector<vector<int> >(w, vector<int>(h));
  colsucc = vector<vector<int> >(w, vector<int>(h));
  rowpred = vector<vector<int> >(h, vector<int>(w));
  rowsucc = vector<vector<int> >(h, vector<int>(w));
  int mx(0), cnt(0);
  for (int i(0); i < (h); i++)
    for (int j(0); j < (w); j++)
      if (a[i][j] >= 0) {
        int re(sim(i, j));
        if (re > mx)
          mx = re, cnt = 1;
        else if (re == mx)
          cnt++;
      }
  cout << mx << " " << cnt << endl;
}
