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>
int n, m, i, j, eid, cur, e, l[5006], r[5006], u[5006], d[5006], L[5006],
    R[5006], D[5006], U[5006], c, res, rc;
short id[5006][5006];
char s[5006][5006], t[5006];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", s[i]);
  for (i = eid = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (s[i][j] != '.') {
        id[i][j] = ++eid;
        t[eid] = s[i][j];
      }
  for (i = 0; i < n; i++) {
    for (j = e = 0; j < m; j++)
      if (s[i][j] != '.') {
        L[id[i][j]] = e;
        e = id[i][j];
      }
    e = 0;
    for (j = m - 1; j >= 0; j--)
      if (s[i][j] != '.') {
        R[id[i][j]] = e;
        e = id[i][j];
      }
  }
  for (j = 0; j < m; j++) {
    for (i = e = 0; i < n; i++)
      if (s[i][j] != '.') {
        U[id[i][j]] = e;
        e = id[i][j];
      }
    e = 0;
    for (i = n - 1; i >= 0; i--)
      if (s[i][j] != '.') {
        D[id[i][j]] = e;
        e = id[i][j];
      }
  }
  for (e = 1; e <= eid; e++) {
    for (i = 1; i <= eid; i++) {
      l[i] = L[i];
      r[i] = R[i];
      u[i] = U[i];
      d[i] = D[i];
    }
    for (c = 0, cur = e; cur != 0; ++c, cur = j) {
      if (t[cur] == 'L') j = l[cur];
      if (t[cur] == 'R') j = r[cur];
      if (t[cur] == 'U') j = u[cur];
      if (t[cur] == 'D') j = d[cur];
      if (l[cur] != 0) r[l[cur]] = r[cur];
      if (r[cur] != 0) l[r[cur]] = l[cur];
      if (u[cur] != 0) d[u[cur]] = d[cur];
      if (d[cur] != 0) u[d[cur]] = u[cur];
    }
    if (c > res) {
      res = c;
      rc = 0;
    }
    if (c == res) rc++;
  }
  printf("%d %d\n", res, rc);
  return 0;
}
