#include <bits/stdc++.h>
using namespace std;
char s[5010][5010];
int U[5050], D[5050], L[5050], R[5050];
int n, m;
void init() {
  for (int i = 0; i < n; ++i) {
    int l = -1;
    for (int j = 0; j < m; ++j)
      if (s[i][j] != '.') {
        int now = i * m + j;
        L[now] = l;
        if (l != -1) R[l] = now;
        l = now;
      }
    R[l] = -1;
  }
  for (int i = 0; i < m; ++i) {
    int l = -1;
    for (int j = 0; j < n; ++j)
      if (s[j][i] != '.') {
        int now = j * m + i;
        U[now] = l;
        if (l != -1) D[l] = now;
        l = now;
      }
    D[l] = -1;
  }
}
int dfs(int x, int y) {
  int now = x * m + y;
  if (U[now] != -1) D[U[now]] = D[now];
  if (D[now] != -1) U[D[now]] = U[now];
  if (L[now] != -1) R[L[now]] = R[now];
  if (R[now] != -1) L[R[now]] = L[now];
  int go;
  if (s[x][y] == 'U')
    go = U[now];
  else if (s[x][y] == 'D')
    go = D[now];
  else if (s[x][y] == 'L')
    go = L[now];
  else if (s[x][y] == 'R')
    go = R[now];
  if (go == -1) return 1;
  return dfs(go / m, go % m) + 1;
}
int main() {
  int ans = -1, num = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] != '.') {
        init();
        int now = dfs(i, j);
        if (now > ans)
          ans = now, num = 1;
        else if (now == ans)
          ++num;
      }
  printf("%d %d\n", ans, num);
  return 0;
}
