#include <bits/stdc++.h>
using namespace std;
typedef struct pointers_ {
  int U, D, R, L;
} pointers;
int r, c;
char m[5010][5010];
pointers* p[5010];
pointers memory[5010];
int pp;
pointers* pmalloc() {
  pointers* point = memory + pp;
  pp += c;
  return point;
}
int run(int i, int j) {
  char old = m[i][j];
  int x = i;
  int y = j;
  switch (m[i][j]) {
    case 'U':
      x = p[x][y].U;
      break;
    case 'D':
      x = p[x][y].D;
      break;
    case 'R':
      y = p[x][y].R;
      break;
    case 'L':
      y = p[x][y].L;
      break;
  }
  m[i][j] = '.';
  int run2 = 0;
  if (x >= 0 and x < r and y >= 0 and y < c) {
    if (p[i][j].L >= 0 and p[i][j].L < c) p[i][p[i][j].L].R = p[i][j].R;
    if (p[i][j].R >= 0 and p[i][j].R < c) p[i][p[i][j].R].L = p[i][j].L;
    if (p[i][j].D >= 0 and p[i][j].D < r) p[p[i][j].D][j].U = p[i][j].U;
    if (p[i][j].U >= 0 and p[i][j].U < r) p[p[i][j].U][j].D = p[i][j].D;
    run2 = run(x, y);
    if (p[i][j].L >= 0 and p[i][j].L < c) p[i][p[i][j].L].R = j;
    if (p[i][j].R >= 0 and p[i][j].R < c) p[i][p[i][j].R].L = j;
    if (p[i][j].D >= 0 and p[i][j].D < r) p[p[i][j].D][j].U = i;
    if (p[i][j].U >= 0 and p[i][j].U < r) p[p[i][j].U][j].D = i;
  }
  m[i][j] = old;
  return 1 + run2;
}
void populate(int i, int j) {
  if (m[i][j] == '.') return;
  int k;
  for (k = i + 1; k < r; k++)
    if (m[k][j] != '.') {
      p[i][j].D = k;
      break;
    }
  if (k == r) p[i][j].D = 0x3f3f3f3f;
  for (k = i - 1; k >= 0; k--)
    if (m[k][j] != '.') {
      p[i][j].U = k;
      break;
    }
  if (k < 0) p[i][j].U = -1;
  for (k = j + 1; k < c; k++)
    if (m[i][k] != '.') {
      p[i][j].R = k;
      break;
    }
  if (k == c) p[i][j].R = 0x3f3f3f3f;
  for (k = j - 1; k >= 0; k--)
    if (m[i][k] != '.') {
      p[i][j].L = k;
      break;
    }
  if (k < 0) p[i][j].L = -1;
  return;
}
int main() {
  scanf("%d %d", &r, &c);
  for (int i = 0; i < r; i++) scanf("%s", m[i]);
  pp = 0;
  for (int i = 0; i < r; i++) p[i] = pmalloc();
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) populate(i, j);
  int maior = 0;
  int qnts = 0;
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      if (m[i][j] != '.') {
        int res = run(i, j);
        if (res > maior) {
          maior = res;
          qnts = 1;
        } else if (res == maior)
          qnts++;
      }
  printf("%d %d\n", maior, qnts);
  return 0;
}
