#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 5;
short dir[4][maxn][maxn];
int h, w;
char mat[maxn][maxn];
void init() {
  for (int i = 0; i < h; ++i) {
    dir[1][i][0] = -1;
    for (int j = 1; j < w; ++j) dir[1][i][j] = j - 1;
    dir[3][i][w - 1] = -1;
    for (int j = w - 2; j >= 0; --j) dir[3][i][j] = j + 1;
  }
  for (int i = 0; i < w; ++i) {
    dir[2][0][i] = -1;
    for (int j = 1; j < h; ++j) dir[2][j][i] = j - 1;
    dir[0][h - 1][i] = -1;
    for (int j = h - 2; j >= 0; --j) dir[0][j][i] = j + 1;
  }
}
void del(int r, int c) {
  int left = dir[1][r][c];
  int right = dir[3][r][c];
  if (left != -1) dir[3][r][left] = right;
  if (right != -1) dir[1][r][right] = left;
  int down = dir[0][r][c];
  int up = dir[2][r][c];
  if (up != -1) dir[0][up][c] = down;
  if (down != -1) dir[2][down][c] = up;
}
int d[][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
struct dat {
  int r, c, d;
  dat(){};
  dat(int p1, int p2, int p3) : r(p1), c(p2), d(p3){};
};
int main() {
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    scanf("%s", mat[i]);
    for (int j = 0; j < w; ++j) {
      if (mat[i][j] == '.')
        mat[i][j] = -1;
      else if (mat[i][j] == 'D')
        mat[i][j] = 0;
      else if (mat[i][j] == 'L')
        mat[i][j] = 1;
      else if (mat[i][j] == 'U')
        mat[i][j] = 2;
      else
        mat[i][j] = 3;
    }
  }
  int mx = 0, cn = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (mat[i][j] == -1) continue;
      init();
      int cnt = 0;
      int r = i, c = j, d = mat[r][c];
      while (r != -1 && c != -1) {
        del(r, c);
        if (mat[r][c] != -1) d = mat[r][c], cnt++;
        if (d == 0 || d == 2)
          r = dir[d][r][c];
        else
          c = dir[d][r][c];
      }
      if (cnt > mx)
        mx = cnt, cn = 1;
      else if (cnt == mx)
        cn++;
    }
  }
  printf("%d %d\n", mx, cn);
  return 0;
}
