#include <bits/stdc++.h>
using namespace std;
const int maxN = 5120;
char maze[maxN][maxN];
int nr, nc;
int L[maxN], R[maxN];
int U[maxN], D[maxN];
void getUDLR() {
  for (int i = 0; i < nr; i++) {
    int l = -1;
    for (int j = 0; j < nc; j++)
      if (maze[i][j] != '.') {
        int idx = i * nc + j;
        L[idx] = l;
        if (l != -1) R[l] = idx;
        l = idx;
      }
    R[l] = -1;
  }
  for (int i = 0; i < nc; i++) {
    int u = -1;
    for (int j = 0; j < nr; j++)
      if (maze[j][i] != '.') {
        int idx = j * nc + i;
        U[idx] = u;
        if (u != -1) D[u] = idx;
        u = idx;
      }
    D[u] = -1;
  }
}
void del(int i, int j) {
  int idx = i * nc + j;
  if (U[idx] != -1) D[U[idx]] = D[idx];
  if (D[idx] != -1) U[D[idx]] = U[idx];
  if (L[idx] != -1) R[L[idx]] = R[idx];
  if (R[idx] != -1) L[R[idx]] = L[idx];
}
int dfs(int i, int j) {
  del(i, j);
  int idx = i * nc + j;
  if (maze[i][j] == 'U') {
    if (U[idx] == -1)
      return 1;
    else
      return 1 + dfs(U[idx] / nc, j);
  } else if (maze[i][j] == 'D') {
    if (D[idx] == -1)
      return 1;
    else
      return 1 + dfs(D[idx] / nc, j);
  } else if (maze[i][j] == 'L') {
    if (L[idx] == -1)
      return 1;
    else
      return 1 + dfs(i, L[idx] % nc);
  } else if (maze[i][j] == 'R') {
    if (R[idx] == -1)
      return 1;
    else
      return 1 + dfs(i, R[idx] % nc);
  }
}
int main() {
  scanf("%d %d", &nr, &nc);
  for (int i = 0; i < nr; i++) scanf("%s", maze[i]);
  int num, max = -1;
  for (int i = 0; i < nr; i++)
    for (int j = 0; j < nc; j++)
      if (maze[i][j] != '.') {
        getUDLR();
        int tmp = dfs(i, j);
        if (tmp > max)
          max = tmp, num = 1;
        else if (tmp == max)
          num++;
      }
  printf("%d %d\n", max, num);
  return 0;
}
