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 maxn = 5001;
struct gtr {
  int x;
  int y;
};
int m, n, i, j, res, x, y, ll, rr, xt, yt, h, k, sl;
int tren[maxn], duoi[maxn], trai[maxn], phai[maxn], up[maxn], down[maxn],
    leftt[maxn], rightt[maxn];
string s[5001];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    s[i] = " " + s[i];
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      ll = (i - 1) * m + j;
      if (i - 1 == 0)
        tren[ll] = 0;
      else if (s[i - 1][j] == '.')
        tren[ll] = tren[(i - 2) * m + j];
      else {
        tren[ll] = (i - 2) * m + j;
      }
      if (j - 1 == 0)
        trai[ll] = 0;
      else if (s[i][j - 1] == '.')
        trai[ll] = trai[(i - 1) * m + j - 1];
      else {
        trai[ll] = (i - 1) * m + j - 1;
      }
    }
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      ll = (i - 1) * m + j;
      if (i + 1 > n)
        duoi[ll] = 0;
      else if (s[i + 1][j] == '.')
        duoi[ll] = duoi[i * m + j];
      else {
        duoi[ll] = i * m + j;
      }
      if (j + 1 > m)
        phai[ll] = 0;
      else if (s[i][j + 1] == '.')
        phai[ll] = phai[(i - 1) * m + j + 1];
      else {
        phai[ll] = (i - 1) * m + j + 1;
      }
    }
  res = 0;
  sl = 1;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (s[i][j] != '.') {
        for (x = 1; x <= n; x++)
          for (y = 1; y <= m; y++) {
            ll = (x - 1) * m + y;
            up[ll] = tren[ll];
            down[ll] = duoi[ll];
            leftt[ll] = trai[ll];
            rightt[ll] = phai[ll];
          }
        rr = 0;
        x = i;
        y = j;
        do {
          ll = (x - 1) * m + y;
          if (s[x][y] == 'U')
            xt = up[ll];
          else if (s[x][y] == 'L')
            xt = leftt[ll];
          else if (s[x][y] == 'R')
            xt = rightt[ll];
          else
            xt = down[ll];
          rr++;
          yt = leftt[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (rightt[ll] == 0)
              rightt[yt] = 0;
            else
              rightt[yt] = rightt[ll];
          }
          yt = rightt[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (leftt[ll] == 0)
              leftt[yt] = 0;
            else
              leftt[yt] = leftt[ll];
          }
          yt = up[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (down[ll] == 0)
              down[yt] = 0;
            else
              down[yt] = down[ll];
          }
          yt = down[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (up[ll] == 0)
              up[yt] = 0;
            else
              up[yt] = up[ll];
          }
          x = (xt - 1) / m + 1;
          y = (xt - 1) % m + 1;
        } while (xt != 0);
        if (res < rr) {
          res = rr;
          sl = 1;
        } else if (res == rr)
          sl++;
      }
  cout << res << " " << sl;
}
