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 INF = 1e8;
const char *dc = "LRUD";
int get(vector<int> &t, int x) {
  assert(x >= 0 && x < ((int)(t).size()));
  if (t[x] == -1) return x;
  return t[x] = get(t, t[x]);
}
const int MAXW = 5000;
char buf[MAXW + 1];
int main() {
  int h, w;
  while (scanf("%d%d", &h, &w) >= 2) {
    vector<string> f(h);
    for (int y = 0; y < h; y++) scanf("%s", buf), f[y] = buf;
    vector<vector<int> > trl(h, vector<int>(w + 2, -1)),
        trr(h, vector<int>(w + 2, -1));
    vector<vector<int> > tru(w, vector<int>(h + 2, -1)),
        trd(w, vector<int>(h + 2, -1));
    int mans = -1, mcnt = 0;
    for (int sy = 0; sy < h; sy++) {
      for (int sx = 0; sx < w; sx++)
        if (f[sy][sx] != '.') {
          for (int y = 0; y < h; y++)
            for (int x = 0; x < w; x++)
              if (f[y][x] == '.') {
                trl[y][x + 1] = x;
                trr[y][x + 1] = x + 2;
                tru[x][y + 1] = y;
                trd[x][y + 1] = y + 2;
                ;
              } else {
                trl[y][x + 1] = trr[y][x + 1] = tru[x][y + 1] = trd[x][y + 1] =
                    -1;
                ;
              }
          int ans = 0;
          int y = sy, x = sx;
          while (1) {
            ans++;
            int d = 0;
            for (; assert(d < 4), dc[d] != f[y][x]; d++)
              ;
            trl[y][x + 1] = x;
            trr[y][x + 1] = x + 2;
            tru[x][y + 1] = y;
            trd[x][y + 1] = y + 2;
            ;
            if (x < 0 || y < 0 || x >= w || y >= h) break;
            switch (d) {
              case 0:
                x = get(trl[y], x + 1) - 1;
                break;
              case 1:
                x = get(trr[y], x + 1) - 1;
                break;
              case 2:
                y = get(tru[x], y + 1) - 1;
                break;
              case 3:
                y = get(trd[x], y + 1) - 1;
                break;
            }
            if (x < 0 || y < 0 || x >= w || y >= h) break;
          }
          if (mans < ans) {
            mans = ans;
            mcnt = 0;
          }
          if (mans == ans) mcnt++;
        }
    }
    printf("%d %d\n", mans, mcnt);
    break;
  }
  return 0;
}
