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;
inline void syy(int &x, int &y, bool f[5002][5002]);
char a[5002][5002];
bool w[5002][5002] = {0};
int i, j, k, l, n, m, t, h, x, y;
void syy(int &x, int &y, bool f[5002][5002]) {
  switch (a[x][y]) {
    case 'U':
      x--;
      while ((a[x][y] == '.' || (a[x][y] != '.' && f[x][y] == true)) && x > 0)
        x--;
      break;
    case 'D':
      x++;
      while ((a[x][y] == '.' || (a[x][y] != '.' && f[x][y] == true)) && x <= n)
        x++;
      break;
    case 'L':
      y--;
      while ((a[x][y] == '.' || (a[x][y] != '.' && f[x][y] == true)) && y > 0)
        y--;
      break;
    case 'R':
      y++;
      while ((a[x][y] == '.' || (a[x][y] != '.' && f[x][y] == true)) && y <= m)
        y++;
      break;
  }
}
void syy1(int x, int y, bool f[5002][5002]) {
  int c[10000] = {0}, d[10000] = {0}, e[10000] = {0}, ch, ct, xx, yy;
  c[1] = x;
  d[1] = y;
  ch = 0;
  ct = 1;
  e[1] = t;
  while (ch < ct) {
    ch++;
    xx = c[ch];
    yy = d[ch];
    xx--;
    while (xx > 0 && xx <= n && yy > 0 && yy <= m && (a[xx][yy] == '.')) xx--;
    if (xx > 0 && xx <= n && yy > 0 && yy <= m && a[xx][yy] == 'D' &&
        !w[xx][yy] && !f[xx][yy]) {
      w[xx][yy] = true;
      ct++;
      c[ct] = xx;
      d[ct] = yy;
      e[ct] = e[ch] + 1;
      if (e[ct] > h) {
        h = e[ct];
        l = 1;
      } else if (h == e[ct])
        l++;
    }
    xx = c[ch] + 1;
    while (xx > 0 && xx <= n && yy > 0 && yy <= m && (a[xx][yy] == '.')) xx++;
    if (xx > 0 && xx <= n && yy > 0 && yy <= m && a[xx][yy] == 'U' &&
        !w[xx][yy] && !f[xx][yy]) {
      w[xx][yy] = true;
      ct++;
      c[ct] = xx;
      d[ct] = yy;
      e[ct] = e[ch] + 1;
      if (e[ct] > h) {
        h = e[ct];
        l = 1;
      } else if (h == e[ct])
        l++;
    }
    xx--;
    yy--;
    while (xx > 0 && xx <= n && yy > 0 && yy <= m && (a[xx][yy] == '.')) yy--;
    if (xx > 0 && xx <= n && yy > 0 && yy <= m && a[xx][yy] == 'R' &&
        !w[xx][yy] && !f[xx][yy]) {
      w[xx][yy] = true;
      ct++;
      c[ct] = xx;
      d[ct] = yy;
      e[ct] = e[ch] + 1;
      if (e[ct] > h) {
        h = e[ct];
        l = 1;
      } else if (h == e[ct])
        l++;
    }
    yy = d[ch] + 1;
    while (xx > 0 && xx <= n && yy > 0 && yy <= m && (a[xx][yy] == '.')) yy++;
    if (xx > 0 && xx <= n && yy > 0 && yy <= m && a[xx][yy] == 'L' &&
        !w[xx][yy] && !f[xx][yy]) {
      w[xx][yy] = true;
      ct++;
      c[ct] = xx;
      d[ct] = yy;
      e[ct] = e[ch] + 1;
      if (e[ct] > h) {
        h = e[ct];
        l = 1;
      } else if (h == e[ct])
        l++;
    }
  }
}
int main() {
  cin >> n >> m;
  getchar();
  h = 0;
  l = 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) scanf("%c", &a[i][j]);
    getchar();
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (a[i][j] != '.' && !w[i][j]) {
        bool f[5002][5002] = {0};
        x = i;
        y = j;
        f[x][y] = true;
        t = 1;
        while (x > 0 && x <= n && y > 0 && y <= m) {
          syy(x, y, f);
          if (x > 0 && x <= n && y > 0 && y <= m) {
            t++;
            f[x][y] = true;
          }
        }
        w[i][j] = true;
        if (t > h) {
          h = t;
          l = 1;
        } else if (h == t)
          l++;
        syy1(i, j, f);
      }
  cout << h << " " << l;
  return 0;
}
