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;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
char arr[5009][5009];
int n, m;
vector<int> L[5009], D[5009], U[5009], R[5009];
int tap0(int x, int y) {
  if (L[x][y] == y) return y;
  return L[x][y] = tap0(x, L[x][y]);
}
int tap1(int x, int y) {
  if (R[x][y] == y) return y;
  return R[x][y] = tap1(x, R[x][y]);
}
int tap2(int x, int y) {
  if (U[x][y] == x) return x;
  return U[x][y] = tap2(U[x][y], y);
}
int tap3(int x, int y) {
  if (D[x][y] == x) return x;
  return D[x][y] = tap3(D[x][y], y);
}
int dfs(int i, int j) {
  L[i][j] = tap0(i, L[i][j - 1]);
  R[i][j] = tap1(i, R[i][j + 1]);
  U[i][j] = tap2(U[i - 1][j], j);
  D[i][j] = tap3(D[i + 1][j], j);
  if (arr[i][j] == 'L') {
    if (tap0(i, j)) return dfs(i, tap0(i, j)) + 1;
    return 1;
  }
  if (arr[i][j] == 'R') {
    if (tap1(i, j)) return dfs(i, tap1(i, j)) + 1;
    return 1;
  }
  if (arr[i][j] == 'U') {
    if (tap2(i, j)) return dfs(tap2(i, j), j) + 1;
    return 1;
  }
  if (arr[i][j] == 'D') {
    if (tap3(i, j)) return dfs(tap3(i, j), j) + 1;
    return 1;
  }
  assert(0);
}
void reset() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (arr[i][j] == '.')
        L[i][j] = tap0(i, L[i][j - 1]);
      else
        L[i][j] = j;
    }
    for (int j = m; j >= 1; j--) {
      if (arr[i][j] == '.')
        R[i][j] = tap1(i, R[i][j + 1]);
      else
        R[i][j] = j;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      if (arr[i][j] == '.')
        U[i][j] = tap2(U[i][j - 1], j);
      else
        U[i][j] = i;
    }
    for (int i = n; i >= 1; i--) {
      if (arr[i][j] == '.')
        D[i][j] = tap3(D[i][j + 1], j);
      else
        D[i][j] = i;
    }
  }
}
int main() {
  srand((unsigned)time(NULL));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    L[i].resize(m + 3);
    R[i].resize(m + 3);
    D[i].resize(m + 3);
    U[i].resize(m + 3);
    for (int j = 1; j <= m; j++) scanf(" %c", &arr[i][j]);
  }
  U[0].resize(m + 3);
  U[n + 1].resize(m + 3);
  D[0].resize(m + 3);
  D[n + 1].resize(m + 3);
  int mx = 0, cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (arr[i][j] != '.') {
        reset();
        int k = dfs(i, j);
        if (umax(mx, k)) cnt = 0;
        if (mx == k) cnt++;
      }
  printf("%d %d\n", mx, cnt);
  return 0;
}
