#include <bits/stdc++.h>
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 5e3 + 5;
const double eps = 1e-9;
using namespace std;
char str[MAXN][MAXN];
int n, m, x[MAXN], y[MAXN], dir[MAXN];
int tmp[MAXN][MAXN], w[MAXN][4], u[MAXN][4];
int dx[4] = {0, 1, -1, 0};
int dy[4] = {-1, 0, 0, 1};
char d[4] = {'L', 'D', 'U', 'R'};
int main() {
  scanf("%d", &(n)), scanf("%d", &(m));
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", str[i]);
    for (int j = 0; j < m; j++) {
      if (str[i][j] == '.') continue;
      x[cnt] = i, y[cnt] = j;
      for (int k = 0; k < 4; k++)
        if (str[i][j] == d[k]) dir[cnt] = k;
      tmp[i][j] = cnt++;
    }
  }
  for (int i = 0; i < cnt; i++)
    for (int k = 0; k < 4; k++) {
      int tx = x[i] + dx[k], ty = y[i] + dy[k];
      w[i][k] = -1;
      while (tx >= 0 && tx < n && ty >= 0 && ty < m) {
        if (str[tx][ty] != '.') {
          w[i][k] = tmp[tx][ty];
          break;
        }
        tx += dx[k], ty += dy[k];
      }
    }
  int a = -1, ans = 0;
  for (int i = 0; i < cnt; i++) {
    int t = i, s = 0;
    for (int j = 0; j < cnt; j++)
      for (int k = 0; k < 4; k++) u[j][k] = w[j][k];
    do {
      s++;
      for (int k = 0; k < 4; k++)
        if (u[t][k] >= 0) u[u[t][k]][3 - k] = u[t][3 - k];
      t = u[t][dir[t]];
    } while (t != -1);
    if (s > a)
      a = s, ans = 1;
    else if (a == s)
      ans++;
  }
  printf("%d %d\n", a, ans);
  return 0;
}
