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;
ifstream fin("in.txt");
ofstream fout("out.txt");
const int MAXN = 5120;
char a[MAXN][MAXN];
int RCON, CCON;
int L[MAXN], R[MAXN];
int U[MAXN], D[MAXN];
void prepare() {
  for (int i = (0); i <= (RCON - 1); i++) {
    int l = -1;
    for (int j = (0); j <= (CCON - 1); j++)
      if (a[i][j] != '.') {
        int ed = i * CCON + j;
        L[ed] = l;
        if (l != -1) R[l] = ed;
        l = ed;
      }
    R[l] = -1;
  }
  for (int i = (0); i <= (CCON - 1); i++) {
    int u = -1;
    for (int j = (0); j <= (RCON - 1); j++)
      if (a[j][i] != '.') {
        int ed = j * CCON + i;
        U[ed] = u;
        if (u != -1) D[u] = ed;
        u = ed;
      }
    D[u] = -1;
  }
}
void del(int i, int j) {
  int ed = i * CCON + j;
  if (U[ed] != -1) D[U[ed]] = D[ed];
  if (D[ed] != -1) U[D[ed]] = U[ed];
  if (L[ed] != -1) R[L[ed]] = R[ed];
  if (R[ed] != -1) L[R[ed]] = L[ed];
}
int dfs(int i, int j) {
  del(i, j);
  int ed = i * CCON + j;
  if (a[i][j] == 'U') {
    if (U[ed] == -1)
      return 1;
    else
      return 1 + dfs(U[ed] / CCON, j);
  } else if (a[i][j] == 'D') {
    if (D[ed] == -1)
      return 1;
    else
      return 1 + dfs(D[ed] / CCON, j);
  } else if (a[i][j] == 'L') {
    if (L[ed] == -1)
      return 1;
    else
      return 1 + dfs(i, L[ed] % CCON);
  } else if (a[i][j] == 'R') {
    if (R[ed] == -1)
      return 1;
    else
      return 1 + dfs(i, R[ed] % CCON);
  }
  return 0;
}
void openfile() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
void init() {
  scanf("%d %d", &RCON, &CCON);
  for (int i = 0; i < RCON; i++) scanf("%s", a[i]);
}
void solve() {
  int ans = -1, ans2;
  for (int i = (0); i <= (RCON - 1); i++)
    for (int j = (0); j <= (CCON - 1); j++)
      if (a[i][j] != '.') {
        prepare();
        int ret = dfs(i, j);
        if (ret > ans)
          ans = ret, ans2 = 1;
        else if (ret == ans)
          ans2++;
      }
  printf("%d %d\n", ans, ans2);
}
int main() {
  init();
  solve();
  return 0;
}
