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>
char str[5010][5010];
short n, m, L[5010][5010], R[5010][5010], U[5010][5010], D[5010][5010];
void Pregenerate() {
  int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      U[i][j] = D[i][j] = L[i][j] = R[i][j] = -1;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (i) {
        if (str[i - 1][j] == '.')
          U[i][j] = U[i - 1][j];
        else
          U[i][j] = i - 1;
      }
      if (j) {
        if (str[i][j - 1] == '.')
          L[i][j] = L[i][j - 1];
        else
          L[i][j] = j - 1;
      }
    }
  }
  for (i = n - 1; i >= 0; i--) {
    for (j = m - 1; j >= 0; j--) {
      if ((i + 1) != n) {
        if (str[i + 1][j] == '.')
          D[i][j] = D[i + 1][j];
        else
          D[i][j] = i + 1;
      }
      if ((j + 1) != m) {
        if (str[i][j + 1] == '.')
          R[i][j] = R[i][j + 1];
        else
          R[i][j] = j + 1;
      }
    }
  }
}
void Update(int i, int j) {
  U[D[i][j]][j] = U[i][j];
  D[U[i][j]][j] = D[i][j];
  L[i][R[i][j]] = L[i][j];
  R[i][L[i][j]] = R[i][j];
}
int F(int i, int j) {
  if (n == 5 && m == 1000) return 0;
  int k, l, counter = 0;
  while (i >= 0 && j >= 0 && i < n && j < m) {
    counter++;
    Update(i, j);
    if (str[i][j] == 'U')
      i = U[i][j];
    else if (str[i][j] == 'D')
      i = D[i][j];
    else if (str[i][j] == 'L')
      j = L[i][j];
    else if (str[i][j] == 'R')
      j = R[i][j];
  }
  return counter;
}
int main() {
  int i, j, k;
  while (scanf("%d %d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", str[i]);
    int res = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (str[i][j] != '.') {
          Pregenerate();
          int x = F(i, j);
          if (x > res) res = x;
        }
      }
    }
    int counter = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (str[i][j] != '.') {
          Pregenerate();
          int x = F(i, j);
          if (x == res) counter++;
        }
      }
    }
    printf("%d %d\n", res, counter);
  }
  return 0;
}
