#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e18;
char mode[5002 / 2][5002];
short int cup[4][5002 / 2][5002];
short int up[4][5002 / 2][5002];
int best = 0, cnt = 0;
inline int geti(int type, int x, int y) {
  if (up[type][x][y] == -1 || (type >= 2 && up[type][x][y] == x) ||
      (type < 2 && up[type][x][y] == y))
    return up[type][x][y];
  int nex = up[type][x][y];
  if (type >= 2) return up[type][x][y] = geti(type, nex, y);
  return up[type][x][y] = geti(type, x, nex);
}
inline void upd(int x, int y) {
  for (int i = 0; i < 2; i++) {
    int plus = (!i ? -1 : 1);
    up[i][x][y] = y + plus;
  }
  for (int i = 0; i < 2; i++) {
    int plus = (!i ? -1 : 1);
    up[i + 2][x][y] = x + plus;
  }
}
int n, m;
int dfs(int i, int j) {
  char c = mode[i][j];
  upd(i, j);
  int out = 1;
  if (c == 'L') {
    int nex = geti(0, i, j);
    if (nex != -1 && nex < m) out = dfs(i, nex) + 1;
  }
  if (c == 'R') {
    int nex = geti(1, i, j);
    if (nex != -1 && nex < m) out = dfs(i, nex) + 1;
  }
  if (c == 'U') {
    int nex = geti(2, i, j);
    if (nex != -1 && nex < n) out = dfs(nex, j) + 1;
  }
  if (c == 'D') {
    int nex = geti(3, i, j);
    if (nex != -1 && nex < n) out = dfs(nex, j) + 1;
  }
  if (out > best) {
    best = out;
    cnt = 0;
  }
  if (out == best) cnt++;
  return out;
}
int main() {
  cin >> n >> m;
  char c;
  scanf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &c);
      if (n < m)
        mode[i][j] = c;
      else {
        if (c == 'U')
          c = 'R';
        else if (c == 'R')
          c = 'D';
        else if (c == 'D')
          c = 'L';
        else if (c != '.')
          c = 'U';
        mode[j][n - 1 - i] = c;
      }
      if (c == '.') continue;
    }
    scanf("\n");
  }
  if (n >= m) swap(n, m);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      cup[1][i][j] = m;
      cup[3][i][j] = n;
    }
  }
  vector<int> pre(m, -1);
  for (int i = 0; i < n; i++) {
    int pp = -1;
    for (int j = 0; j < m; j++) {
      if (mode[i][j] != '.') {
        pre[j] = i;
        pp = j;
      }
      cup[0][i][j] = pp;
      cup[2][i][j] = pre[j];
    }
  }
  pre.assign(m, n);
  for (int i = n - 1; i >= 0; i--) {
    int pp = m;
    for (int j = m - 1; j >= 0; j--) {
      if (mode[i][j] != '.') {
        pre[j] = i;
        pp = j;
      }
      cup[1][i][j] = pp;
      cup[3][i][j] = pre[j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) {
        for (int i2 = 0; i2 <= n; i2++) {
          for (int j2 = 0; j2 <= m; j2++) {
            up[k][i2][j2] = cup[k][i2][j2];
          }
        }
      }
      if (mode[i][j] != '.') dfs(i, j);
    }
  }
  cout << best << " " << cnt;
}
