#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > g;
int n, m;
vector<vector<int> > nxtcol1, prvcol1, nxtrow1, prvrow1;
int solve(int r, int c) {
  int ret = 0;
  while (true) {
    if (r >= n || c >= m) break;
    ret++;
    int i = r, j = c;
    if (g[r][c] == 'L') {
      c = prvcol1[r][j];
      nxtcol1[r][c] = nxtcol1[r][j];
      prvcol1[r][nxtcol1[r][j]] = c;
      nxtrow1[prvrow1[r][j]][j] = nxtrow1[r][j];
      prvrow1[nxtrow1[r][j]][j] = prvrow1[r][j];
    } else if (g[r][c] == 'R') {
      c = nxtcol1[r][j];
      prvcol1[r][c] = prvcol1[r][j];
      nxtcol1[r][prvcol1[r][j]] = c;
      nxtrow1[prvrow1[r][j]][j] = nxtrow1[r][j];
      prvrow1[nxtrow1[r][j]][j] = prvrow1[r][j];
    } else if (g[r][c] == 'U') {
      r = prvrow1[r][c];
      nxtrow1[r][c] = nxtrow1[i][c];
      prvrow1[nxtrow1[i][c]][c] = r;
      nxtcol1[i][prvcol1[i][c]] = nxtcol1[i][c];
      prvcol1[i][nxtcol1[i][c]] = prvcol1[i][c];
    } else if (g[r][c] == 'D') {
      r = nxtrow1[r][c];
      prvrow1[r][c] = prvrow1[i][c];
      nxtrow1[prvrow1[i][c]][c] = r;
      nxtcol1[i][prvcol1[i][c]] = nxtcol1[i][c];
      prvcol1[i][nxtcol1[i][c]] = prvcol1[i][c];
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  g.resize(n + 5);
  vector<vector<int> > nxtcol(n + 5, vector<int>(m + 5));
  vector<vector<int> > prvcol(n + 5, vector<int>(m + 5));
  vector<vector<int> > nxtrow(n + 5, vector<int>(m + 5));
  vector<vector<int> > prvrow(n + 5, vector<int>(m + 5));
  for (int i = 0; i < n; i++) {
    g[i].resize(m + 5);
    for (int j = 0; j < m; j++) cin >> g[i][j];
  }
  for (int i = 0; i < n; i++) {
    int last = m;
    for (int j = m - 1; j >= 0; j--) {
      if (g[i][j] != '.') {
        nxtcol[i][j] = last;
        prvcol[i][last] = j;
        last = j;
      }
    }
    prvcol[i][last] = m + 1;
  }
  for (int i = 0; i < m; i++) {
    int last = n;
    for (int j = n - 1; j >= 0; j--) {
      if (g[j][i] != '.') {
        nxtrow[j][i] = last;
        prvrow[last][i] = j;
        last = j;
      }
    }
    prvrow[last][i] = n + 1;
  }
  int ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] != '.') {
        nxtcol1 = nxtcol;
        prvcol1 = prvcol;
        nxtrow1 = nxtrow;
        prvrow1 = prvrow;
        int temp = solve(i, j);
        if (ans < temp)
          ans = temp, cnt = 1;
        else if (ans == temp)
          cnt++;
      }
    }
  }
  cout << ans << " " << cnt << endl;
  return 0;
}
