#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
char arr[5009][5009];
int n, m;
vector<int> L[5009], D[5009], U[5009], R[5009];
int tap0(int x, int y) {
  if (L[x][y] == y) return y;
  return L[x][y] = tap0(x, L[x][y]);
}
int tap1(int x, int y) {
  if (R[x][y] == y) return y;
  return R[x][y] = tap1(x, R[x][y]);
}
int tap2(int x, int y) {
  if (U[x][y] == x) return x;
  return U[x][y] = tap2(U[x][y], y);
}
int tap3(int x, int y) {
  if (D[x][y] == x) return x;
  return D[x][y] = tap3(D[x][y], y);
}
int dfs(int i, int j) {
  L[i][j] = tap0(i, L[i][j - 1]);
  R[i][j] = tap1(i, R[i][j + 1]);
  U[i][j] = tap2(U[i - 1][j], j);
  D[i][j] = tap3(D[i + 1][j], j);
  if (arr[i][j] == 'L') {
    if (tap0(i, j)) return dfs(i, tap0(i, j)) + 1;
    return 1;
  }
  if (arr[i][j] == 'R') {
    if (tap1(i, j)) return dfs(i, tap1(i, j)) + 1;
    return 1;
  }
  if (arr[i][j] == 'U') {
    if (tap2(i, j)) return dfs(tap2(i, j), j) + 1;
    return 1;
  }
  if (arr[i][j] == 'D') {
    if (tap3(i, j)) return dfs(tap3(i, j), j) + 1;
    return 1;
  }
  assert(0);
}
void reset() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (arr[i][j] == '.')
        L[i][j] = tap0(i, L[i][j - 1]);
      else
        L[i][j] = j;
    }
    for (int j = m; j >= 1; j--) {
      if (arr[i][j] == '.')
        R[i][j] = tap1(i, R[i][j + 1]);
      else
        R[i][j] = j;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      if (arr[i][j] == '.')
        U[i][j] = tap2(U[i - 1][j], j);
      else
        U[i][j] = i;
    }
    for (int i = n; i >= 1; i--) {
      if (arr[i][j] == '.')
        D[i][j] = tap3(D[i + 1][j], j);
      else
        D[i][j] = i;
    }
  }
}
int main() {
  srand((unsigned)time(NULL));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    L[i].resize(m + 3);
    R[i].resize(m + 3);
    D[i].resize(m + 3);
    U[i].resize(m + 3);
    for (int j = 1; j <= m; j++) scanf(" %c", &arr[i][j]);
  }
  U[0].resize(m + 3);
  U[n + 1].resize(m + 3);
  D[0].resize(m + 3);
  D[n + 1].resize(m + 3);
  int mx = 0, cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (arr[i][j] != '.') {
        reset();
        int k = dfs(i, j);
        if (umax(mx, k)) cnt = 0;
        if (mx == k) cnt++;
      }
  printf("%d %d\n", mx, cnt);
  return 0;
}
