#include <bits/stdc++.h>
char** mm;
int n, m;
int **le, **ri, **up, **down;
bool** used;
void init_ar(int** p, int n, int m) {
  p = new int*[n];
  int i;
  for (i = 0; i < n; i++) p[i] = new int[m];
}
void init_next() {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (i == 0 || mm[i - 1][j] != '.')
        up[i][j] = i - 1;
      else
        up[i][j] = up[i - 1][j];
      if (j == 0 || mm[i][j - 1] != '.')
        le[i][j] = j - 1;
      else
        le[i][j] = le[i][j - 1];
    }
  for (i = n - 1; i >= 0; i--)
    for (j = m - 1; j >= 0; j--) {
      if (i == n - 1 || mm[i + 1][j] != '.')
        down[i][j] = i + 1;
      else
        down[i][j] = down[i + 1][j];
      if (j == m - 1 || mm[i][j + 1] != '.')
        ri[i][j] = j + 1;
      else
        ri[i][j] = ri[i][j + 1];
    }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) used[i][j] = 0;
}
bool valid(int y, int x) { return (y >= 0 && y < n && x >= 0 && x < m); }
int get_ver(int** com, int y, int x) {
  if (!valid(y, x)) return y;
  if (!used[y][x]) return y;
  return com[y][x] = get_ver(com, com[y][x], x);
}
int get_hor(int** com, int y, int x) {
  if (!valid(y, x)) return x;
  if (!used[y][x]) return x;
  return com[y][x] = get_hor(com, y, com[y][x]);
}
int proc(int y, int x) {
  init_next();
  int it;
  for (it = 0;; it++) {
    if (!valid(y, x)) break;
    used[y][x] = true;
    if (mm[y][x] == 'D')
      y = get_ver(down, y, x);
    else if (mm[y][x] == 'U')
      y = get_ver(up, y, x);
    else if (mm[y][x] == 'L')
      x = get_hor(le, y, x);
    else if (mm[y][x] == 'R')
      x = get_hor(ri, y, x);
  }
  return it;
}
int main() {
  scanf("%d %d", &n, &m);
  mm = new char*[n];
  le = new int*[n];
  ri = new int*[n];
  up = new int*[n];
  down = new int*[n];
  used = new bool*[n];
  int i, j;
  for (i = 0; i < n; i++) {
    mm[i] = new char[m + 1];
    le[i] = new int[m];
    ri[i] = new int[m];
    up[i] = new int[m];
    down[i] = new int[m];
    used[i] = new bool[m];
  }
  for (i = 0; i < n; i++) scanf("%s", mm[i]);
  int res = 0;
  int nres = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (mm[i][j] != '.') {
        int tmp = proc(i, j);
        if (tmp > res) {
          res = tmp;
          nres = 1;
        } else if (tmp == res) {
          nres++;
        }
      }
  printf("%d %d\n", res, nres);
  return 0;
}
