#include <bits/stdc++.h>
int n, m;
char str[5010][5010];
int **L, **R, **U, **D;
void Allocate() {
  int i;
  L = (int **)malloc(n * sizeof(int *));
  for (i = 0; i < n; i++) L[i] = (int *)malloc(m * sizeof(int));
  R = (int **)malloc(n * sizeof(int *));
  for (i = 0; i < n; i++) R[i] = (int *)malloc(m * sizeof(int));
  U = (int **)malloc(n * sizeof(int *));
  for (i = 0; i < n; i++) U[i] = (int *)malloc(m * sizeof(int));
  D = (int **)malloc(n * sizeof(int *));
  for (i = 0; i < n; i++) D[i] = (int *)malloc(m * sizeof(int));
}
void Pregenerate() {
  int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      U[i][j] = D[i][j] = L[i][j] = R[i][j] = -1;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (i) {
        if (str[i - 1][j] == '.')
          U[i][j] = U[i - 1][j];
        else
          U[i][j] = i - 1;
      }
      if (j) {
        if (str[i][j - 1] == '.')
          L[i][j] = L[i][j - 1];
        else
          L[i][j] = j - 1;
      }
    }
  }
  for (i = n - 1; i >= 0; i--) {
    for (j = m - 1; j >= 0; j--) {
      if ((i + 1) != n) {
        if (str[i + 1][j] == '.')
          D[i][j] = D[i + 1][j];
        else
          D[i][j] = i + 1;
      }
      if ((j + 1) != m) {
        if (str[i][j + 1] == '.')
          R[i][j] = R[i][j + 1];
        else
          R[i][j] = j + 1;
      }
    }
  }
}
void Update(int i, int j) {
  if (D[i][j] != -1) U[D[i][j]][j] = U[i][j];
  if (U[i][j] != -1) D[U[i][j]][j] = D[i][j];
  if (R[i][j] != -1) L[i][R[i][j]] = L[i][j];
  if (L[i][j] != -1) R[i][L[i][j]] = R[i][j];
}
int F(int i, int j) {
  int k, l, counter = 0;
  while (i >= 0 && j >= 0 && i < n && j < m) {
    counter++;
    Update(i, j);
    if (str[i][j] == 'U')
      i = U[i][j];
    else if (str[i][j] == 'D')
      i = D[i][j];
    else if (str[i][j] == 'L')
      j = L[i][j];
    else if (str[i][j] == 'R')
      j = R[i][j];
  }
  return counter;
}
int main() {
  int i, j, k;
  while (scanf("%d %d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", str[i]);
    Allocate();
    int res = 0, counter = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (str[i][j] != '.') {
          Pregenerate();
          int x = F(i, j);
          if (x > res)
            res = x, counter = 1;
          else if (x == res)
            counter++;
        }
      }
    }
    printf("%d %d\n", res, counter);
  }
  return 0;
}
