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;
const int MAX_HW = 5000;
const char dcs[] = "RULD";
const int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0, 1};
int dcmap[128];
char s[MAX_HW + 4], fs0[MAX_HW], fs1[MAX_HW];
short nbs0[MAX_HW][4], nbs1[MAX_HW][4];
inline bool inside(int x, int y, int w, int h) {
  return x >= 0 && x < w && y >= 0 && y < h;
}
inline void remcell(short (*nbs)[4], int p) {
  for (int di0 = 0; di0 < 4; di0++) {
    int di1 = (di0 ^ 2), p0 = nbs[p][di0];
    if (p0 >= 0) nbs[p0][di1] = nbs[p][di1];
  }
}
int main() {
  for (int i = 0; i < 4; i++) dcmap[dcs[i]] = i;
  dcmap['.'] = -1;
  int h, w;
  scanf("%d%d", &h, &w);
  int hw = h * w;
  int dps[4] = {1, -w, -1, w};
  for (int y = 0, p = 0; y < h; y++) {
    scanf("%s", s);
    for (int x = 0; x < w; x++, p++) {
      fs0[p] = dcmap[s[x]];
      for (int di = 0; di < 4; di++)
        nbs0[p][di] = inside(x + dxs[di], y + dys[di], w, h) ? p + dps[di] : -1;
    }
  }
  for (int p = 0; p < hw; p++)
    if (fs0[p] < 0) remcell(nbs0, p);
  int maxr = 0, maxc = 0;
  for (int st = 0; st < hw; st++)
    if (fs0[st] >= 0) {
      int p = st, r = 0;
      memcpy(fs1, fs0, sizeof(fs0));
      memcpy(nbs1, nbs0, sizeof(nbs0));
      while (p >= 0) {
        int ndi = fs1[p];
        fs1[p] = -1;
        remcell(nbs1, p);
        r++;
        p = nbs1[p][ndi];
      }
      if (maxr < r)
        maxr = r, maxc = 1;
      else if (maxr == r)
        maxc++;
    }
  printf("%d %d\n", maxr, maxc);
  return 0;
}
