10 10
.L.....R..
.........U
..D....D..
.R......L.
....L.....
.........D
......U...
D....R....
...U......
........L.
 5 5
DD..D
.....
LU...
U...U
.UL.U
 1 1
U
 5 5
UD..L
RRD..
..RDD
UUL..
DDLRR
 19 23
U..U..R........L...D...
.D.....UL.U.U........DR
..D.U..D....L......R...
D.......RL.L....D.....R
U..D.....U...U.L..D...U
...........L...........
U....U....D.U......LRR.
......RL...U...L.......
DLU..U......UU.U.U.D...
...........D....U......
U...DL......LL.....R...
...U..DD..........LD...
.R.........D.....UU...U
....D......R..........D
.L..........R.....L....
.R........L.LL....R....
..R...D........R....D..
.LR.R..LDU.DDRL......U.
...LL.....D.....DD.....
 11 29
URRUUDDLURLRDDLLRLDUDR.UDLLD.
LRRUDLUDLDULUDL.DURDRR.RRLLRR
D.DUDDURLRDDULDUDDUDDURRDLD.L
.RULURURRDLRRRLUUUU.RDLDLRRRL
.RLDDU.UUULUURURRLLUU.RLDRDUD
LRL.URRRDDURUURUDRRDLDDULRDRL
RLULDU.LRDUDRLDLRDDDDRUUDRDLL
DLUDURRDDUDLLDLLUURLDRUURRLUL
L.RRURRDDRRURRRDDUDRRDULR.LUR
LDLRULURRUULRDUUULLU.LLU.LLLL
DUURDULDDUDLRUUDRUULURLD.RL.U
 2 2
RD
UL
 1 10
LLLLLRRRRR
 3 3
...
...
..R
 17 13
...LD.UR.RUU.
LDLULDUDRRDRL
DD.RRLRUR.UD.
RU...D...LD..
.UR.R...URUUD
.RURD.RLR.D.R
.UUU.RU...UR.
UUUU.R.......
RL.LRU.UD.DUD
LD.DRURRLRDRL
.DR..UULUDDR.
LRLURRUUDDLUR
.LRDDLLR.L.DU
DRUDLLD.LRRU.
..DL.UDL.DUL.
U.DL..D..U.RD
RR.R...RL.L..

2 2
 4 1
 1 1
 8 3
 9 1
 94 1
 4 4
 5 2
 1 1
 24 2

#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;
}
