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;
struct p {
  int L, R, U, D;
} point[5005], pos[5005];
string g[5005];
void DEL(int x) {
  pos[pos[x].D].U = pos[x].U;
  pos[pos[x].U].D = pos[x].D;
  pos[pos[x].R].L = pos[x].L;
  pos[pos[x].L].R = pos[x].R;
}
int main() {
  int m, n, i, j, l, sx, sy;
  scanf("%d%d", &m, &n);
  for (i = 0; i < m; i++) cin >> g[i];
  n = g[0].size();
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      if (g[i][j] != '.') {
        for (l = i - 1; l >= 0; l--)
          if (g[l][j] != '.') break;
        if (l < 0)
          point[i * n + j].U = -1;
        else
          point[i * n + j].U = l * n + j;
        for (l = i + 1; l < m; l++)
          if (g[l][j] != '.') break;
        if (l >= m)
          point[i * n + j].D = -1;
        else
          point[i * n + j].D = l * n + j;
        for (l = j - 1; l >= 0; l--)
          if (g[i][l] != '.') break;
        if (l < 0)
          point[i * n + j].L = -1;
        else
          point[i * n + j].L = i * n + l;
        for (l = j + 1; l < n; l++)
          if (g[i][l] != '.') break;
        if (l >= n)
          point[i * n + j].R = -1;
        else
          point[i * n + j].R = i * n + l;
      }
    }
  }
  int r1 = 0, r2 = 0, cnt, t, x, y;
  for (sx = 0; sx < m; sx++) {
    for (sy = 0; sy < n; sy++)
      if (g[sx][sy] != '.') {
        for (i = 0; i < m; i++) {
          for (j = 0; j < n; j++) {
            pos[i * n + j] = point[i * n + j];
          }
        }
        if (g[sx][sy] == 'D')
          t = pos[sx * n + sy].D;
        else if (g[sx][sy] == 'U')
          t = pos[sx * n + sy].U;
        else if (g[sx][sy] == 'R')
          t = pos[sx * n + sy].R;
        else if (g[sx][sy] == 'L')
          t = pos[sx * n + sy].L;
        DEL(sx * n + sy);
        cnt = 1;
        while (t != -1) {
          cnt++;
          x = t / n;
          y = t % n;
          DEL(t);
          if (g[x][y] == 'D')
            t = pos[t].D;
          else if (g[x][y] == 'U')
            t = pos[t].U;
          else if (g[x][y] == 'R')
            t = pos[t].R;
          else if (g[x][y] == 'L')
            t = pos[t].L;
        }
        if (cnt > r1) {
          r1 = cnt;
          r2 = 1;
        } else if (cnt == r1) {
          r2++;
        }
      }
  }
  printf("%d %d\n", r1, r2);
}
