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 a[5005][5005] = {0};
long b[5005][5005] = {0};
struct case1 {
  long pre, next;
  long up, down;
  char ch;
} c[5005] = {0};
int main() {
  long n, m, i, j;
  long max = 0, num = 0;
  long o = 0, p, q;
  long last;
  long x, s = 0, xx;
  scanf("%ld%ld", &n, &m);
  for (i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (a[i][j] != '.') b[i][j] = ++o;
  for (p = 1; p <= n; p++)
    for (q = 1; q <= m; q++)
      if (a[p][q] != '.') {
        for (i = 1; i <= n; i++) {
          last = 0;
          for (j = 1; j <= m; j++)
            if (b[i][j]) {
              c[b[i][j]].ch = a[i][j];
              c[b[i][j]].pre = last;
              c[b[i][j]].next = 0;
              c[last].next = b[i][j];
              last = b[i][j];
            }
        }
        for (j = 1; j <= m; j++) {
          last = 0;
          for (i = 1; i <= n; i++)
            if (b[i][j]) {
              c[b[i][j]].up = last;
              c[b[i][j]].down = 0;
              c[last].down = b[i][j];
              last = b[i][j];
            }
        }
        for (x = b[p][q], s = 0; x; s++) {
          if (c[x].ch == 'U') xx = c[x].up;
          if (c[x].ch == 'D') xx = c[x].down;
          if (c[x].ch == 'L') xx = c[x].pre;
          if (c[x].ch == 'R') xx = c[x].next;
          c[c[x].up].down = c[x].down;
          c[c[x].down].up = c[x].up;
          c[c[x].pre].next = c[x].next;
          c[c[x].next].pre = c[x].pre;
          x = xx;
        }
        if (s > max)
          max = s, num = 1;
        else if (s == max)
          max = s, num++;
      }
  printf("%ld %ld\n", max, num);
  return 0;
}
