#include <bits/stdc++.h>
using namespace std;
const int maxn = 5001;
char a[maxn][maxn];
int b[maxn][maxn], d[maxn], x[maxn], y[maxn];
int f[maxn][4], g[maxn][4];
int n, m, tot;
int solve(int k) {
  int i, s = 0;
  memcpy(g, f, sizeof(f));
  i = k;
  while (i) {
    s++;
    g[g[i][0]][1] = g[i][1];
    g[g[i][1]][0] = g[i][0];
    g[g[i][2]][3] = g[i][3];
    g[g[i][3]][2] = g[i][2];
    i = g[i][d[i]];
  }
  return s;
}
void init(int k, int x, int y) {
  int i;
  for (i = x - 1; i >= 0; i--)
    if (a[i][y] != '.') {
      f[k][0] = b[i][y];
      break;
    }
  for (i = x + 1; i < n; i++)
    if (a[i][y] != '.') {
      f[k][1] = b[i][y];
      break;
    }
  for (i = y - 1; i >= 0; i--)
    if (a[x][i] != '.') {
      f[k][2] = b[x][i];
      break;
    }
  for (i = y + 1; i < m; i++)
    if (a[x][i] != '.') {
      f[k][3] = b[x][i];
      break;
    }
}
int main() {
  int i, j, k, s = 0, t = 1;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%s", a[i]);
    for (j = 0; j < m; j++)
      if (a[i][j] != '.') {
        tot++;
        b[i][j] = tot;
        x[tot] = i;
        y[tot] = j;
        if (a[i][j] == 'U')
          d[tot] = 0;
        else if (a[i][j] == 'D')
          d[tot] = 1;
        else if (a[i][j] == 'L')
          d[tot] = 2;
        else if (a[i][j] == 'R')
          d[tot] = 3;
      }
  }
  for (i = 1; i <= tot; i++) init(i, x[i], y[i]);
  for (i = 1; i <= tot; i++) {
    k = solve(i);
    if (k > s) {
      s = k;
      t = 1;
    } else if (k == s)
      t++;
  }
  printf("%d %d\n", s, t);
  return 0;
}
