#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
short **nd, **nu, **nl, **nr;
char field[N][N];
int n, m;
int last;
inline void del(int x, int y) {
  if (nu[x][y] != -1) nd[nu[x][y]][y] = nd[x][y];
  if (nd[x][y] != -1) nu[nd[x][y]][y] = nu[x][y];
  if (nl[x][y] != -1) nr[x][nl[x][y]] = nr[x][y];
  if (nr[x][y] != -1) nl[x][nr[x][y]] = nl[x][y];
}
inline void recover(int x, int y) {
  if (nu[x][y] != -1) nd[nu[x][y]][y] = x;
  if (nd[x][y] != -1) nu[nd[x][y]][y] = x;
  if (nl[x][y] != -1) nr[x][nl[x][y]] = y;
  if (nr[x][y] != -1) nl[x][nr[x][y]] = y;
}
int getInt(char delim) {
  int ret = 0;
  char c;
  while ((c = getchar()) != delim) ret = ret * 10 + c - '0';
  return ret;
}
inline void build() {
  for (int i = 0; i < n; i++) {
    last = -1;
    for (int j = 0; j < m; j++)
      if (field[i][j] != '.') {
        nl[i][j] = last;
        last = j;
      }
    last = -1;
    for (int j = m - 1; j >= 0; j--)
      if (field[i][j] != '.') {
        nr[i][j] = last;
        last = j;
      }
  }
  for (int j = 0; j < m; j++) {
    last = -1;
    for (int i = 0; i < n; i++)
      if (field[i][j] != '.') {
        nu[i][j] = last;
        last = i;
      }
    last = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (field[i][j] != '.') {
        nd[i][j] = last;
        last = i;
      }
    }
  }
}
int main() {
  n = getInt(' ');
  m = getInt('\n');
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      field[i][j] = getchar();
    }
    getchar();
  }
  nu = new short *[n + 1];
  nr = new short *[n + 1];
  nl = new short *[n + 1];
  nd = new short *[n + 1];
  for (int i = 0; i < n; i++) {
    nu[i] = new short[m + 1];
    nr[i] = new short[m + 1];
    nl[i] = new short[m + 1];
    nd[i] = new short[m + 1];
  }
  int maxAns = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (field[i][j] != '.') {
        int cur = 1;
        int x = i, y = j;
        int nx = x, ny = y;
        build();
        while (true) {
          const char cmd = field[x][y];
          if (cmd == 'L')
            ny = nl[nx][ny];
          else if (cmd == 'R')
            ny = nr[nx][ny];
          else if (cmd == 'U')
            nx = nu[nx][ny];
          else
            nx = nd[nx][ny];
          if (nx == -1 || ny == -1) break;
          del(x, y);
          cur++;
          x = nx;
          y = ny;
        }
        if (cur > maxAns) {
          maxAns = cur;
          cnt = 1;
        } else if (cur == maxAns)
          cnt++;
      }
  }
  printf("%d %d\n", maxAns, cnt);
  return 0;
}
