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;
int n, ans = 0, m, up[5005], dw[5005], pr[5005], nx[5005];
int upp[5005], dww[5005], prr[5005], nxx[5005];
char mp[5005][5005];
inline void initialize() {
  for (int k = 0; k < n; k++)
    for (int l = 0; l < m; l++) {
      up[k * m + l] = upp[k * m + l];
      dw[k * m + l] = dww[k * m + l];
      nx[k * m + l] = nxx[k * m + l];
      pr[k * m + l] = prr[k * m + l];
    }
}
inline void del(int x) {
  nx[pr[x]] = nx[x];
  pr[nx[x]] = pr[x];
  up[dw[x]] = up[x];
  dw[up[x]] = dw[x];
}
int main() {
  int t = 0, T = 0;
  scanf("%d%d", &n, &m);
  getchar();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%c", &mp[i][j]);
    getchar();
  }
  memset(up, -1, sizeof(up));
  memset(dw, -1, sizeof(dw));
  memset(nx, -1, sizeof(nx));
  memset(pr, -1, sizeof(pr));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.') continue;
      for (int k = i - 1; k >= 0; k--)
        if (mp[k][j] != '.') {
          up[i * m + j] = k * m + j;
          break;
        }
      for (int k = i + 1; k < n; k++)
        if (mp[k][j] != '.') {
          dw[i * m + j] = k * m + j;
          break;
        }
      for (int k = j + 1; k < m; k++)
        if (mp[i][k] != '.') {
          nx[i * m + j] = i * m + k;
          break;
        }
      for (int k = j - 1; k >= 0; k--)
        if (mp[i][k] != '.') {
          pr[i * m + j] = i * m + k;
          break;
        }
    }
  }
  for (int k = 0; k < n; k++)
    for (int l = 0; l < m; l++) {
      upp[k * m + l] = up[k * m + l];
      dww[k * m + l] = dw[k * m + l];
      nxx[k * m + l] = nx[k * m + l];
      prr[k * m + l] = pr[k * m + l];
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.') continue;
      int x = i, y = j, len = 1;
      initialize();
      del(i * m + j);
      while (1) {
        int k = x * m + y;
        if (mp[x][y] == 'U' && up[k] >= 0)
          x = up[k] / m;
        else if (mp[x][y] == 'D' && dw[k] >= 0)
          x = dw[k] / m;
        else if (mp[x][y] == 'R' && nx[k] >= 0)
          y = nx[k] % m;
        else if (mp[x][y] == 'L' && pr[k] >= 0)
          y = pr[k] % m;
        else
          break;
        del(k);
        len++;
      }
      if (len > ans)
        ans = len, T = 1;
      else if (len == ans)
        T++;
    }
  }
  printf("%d %d\n", ans, T);
  return 0;
}
