#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
short H[1 << 17];
int W;
struct DSU {
  short *C, *X, *Y;
  int gc(int a) { return C[a] = (a == C[a] ? a : gc(C[a])); }
  bool con(int a, int b) {
    if (gc(a) == gc(b)) return 0;
    X[gc(a)] = min(X[gc(a)], X[gc(b)]);
    Y[gc(a)] = max(Y[gc(a)], Y[gc(b)]);
    C[gc(b)] = gc(a);
    return 1;
  }
  void ini(int N) {
    C = H + W, W += N + 1, X = H + W, W += N + 1, Y = H + W, W += N + 1;
  }
  void CLR(int N) { iota(C, C + N, 0), iota(X, X + N, 0), iota(Y, Y + N, 0); }
  int mn(int a) { return X[gc(a)]; }
  int mx(int a) { return Y[gc(a)]; }
} R[5005], C[5005];
bool V[5005][5005];
char s[5005][5005];
int N, M, B, I;
void go(int x, int y) {
  for (int i(0); i < N; i++)
    for (int j(0); j < M; j++) V[i][j] = 0;
  for (int i(0); i < N; i++) R[i].CLR(M);
  for (int i(0); i < M; i++) C[i].CLR(N);
  int S = 0, a;
  while (666) {
    V[x][y]++, ++S;
    if (s[x][y] == 'R')
      while (666) {
        a = R[x].mx(y) + 1;
        if (a == M) goto https;
        if (V[x][a] || s[x][a] == 46) {
          R[x].con(y, a);
          continue;
        }
        R[x].con(y, a), y = a;
        break;
      }
    else if (s[x][y] == 'L')
      while (666) {
        a = R[x].mn(y) - 1;
        if (!~a) goto https;
        if (V[x][a] || s[x][a] == 46) {
          R[x].con(y, a);
          continue;
        }
        R[x].con(y, a), y = a;
        break;
      }
    else if (s[x][y] == 'D')
      while (666) {
        a = C[y].mx(x) + 1;
        if (a == N) goto https;
        if (V[a][y] || s[a][y] == 46) {
          C[y].con(x, a);
          continue;
        }
        C[y].con(x, a), x = a;
        break;
      }
    else {
      while (666) {
        a = C[y].mn(x) - 1;
        if (!~a) goto https;
        if (V[a][y] || s[a][y] == 46) {
          C[y].con(x, a);
          continue;
        }
        C[y].con(x, a), x = a;
        break;
      }
    }
  }
https:
  if (S > B) B = S, I = 0;
  I += S == B;
}
int main(void) {
  scanf("%d%d", &N, &M);
  for (int i(0); i < N; i++) R[i].ini(M);
  for (int i(0); i < M; i++) C[i].ini(N);
  for (int i(0); i < N; i++) scanf("%s", s[i]);
  for (int i(0); i < N; i++)
    for (int j(0); j < M; j++)
      if (s[i][j] ^ 46) go(i, j);
  printf("%d %d\n", B, I);
  return 0;
}
