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 wait(double seconds) {
  double endtime = clock() + (seconds * CLOCKS_PER_SEC);
  while (clock() < endtime) {
    ;
  }
}
inline int fastIn() {
  register char c = 0;
  register int a = 0;
  while (c < 33) c = getchar();
  while (c > 33) {
    a = (a * 10) + (c - '0');
    c = getchar();
  }
  return a;
}
const int MX = 5005;
int R, C;
char buff[MX];
string grid[MX];
inline void read() {
  scanf("%d %d\n", &R, &C);
  for (int i = 0, j1 = R; i < j1; ++i)
    scanf(" %s", buff), grid[i] = (string)buff;
}
inline int encodeRC(int r, int c) { return (r * C + c); }
inline int decodeR(int val) { return val / C; }
inline int decodeC(int val) { return val % C; }
struct info {
  int U[MX];
  int D[MX];
  int L[MX];
  int R[MX];
  inline void clear() {
    memset(U, 0, sizeof(U)), memset(D, 0, sizeof(D)), memset(L, 0, sizeof(L)),
        memset(R, 0, sizeof(R));
  }
};
info A, B;
inline void mycopy() {
  memcpy(B.U, A.U, sizeof(A.U));
  memcpy(B.D, A.D, sizeof(A.D));
  memcpy(B.L, A.L, sizeof(A.L));
  memcpy(B.R, A.R, sizeof(A.R));
}
const int inf = 1023456789;
inline void preprocess() {
  A.clear();
  for (int i = 0; i < R; ++i) {
    int cnt = -1, ccnt = -1;
    for (int j = 0; j < C; ++j) {
      if (grid[i][j] != '.') A.L[encodeRC(i, j)] = cnt, cnt = encodeRC(i, j);
      if (grid[i][(C - 1) - j] != '.')
        A.R[encodeRC(i, (C - 1) - j)] = ccnt, ccnt = encodeRC(i, (C - 1) - j);
    }
  }
  for (int j = 0; j < C; ++j) {
    int cnt = -1, ccnt = -1;
    for (int i = 0; i < R; ++i) {
      if (grid[i][j] != '.') A.U[encodeRC(i, j)] = cnt, cnt = encodeRC(i, j);
      if (grid[(R - 1) - i][j] != '.')
        A.D[encodeRC((R - 1) - i, j)] = ccnt, ccnt = encodeRC((R - 1) - i, j);
    }
  }
}
inline bool move(char ch, int &tmp) {
  int li = B.L[tmp], ri = B.R[tmp], ui = B.U[tmp], di = B.D[tmp];
  if (li != -1) B.R[li] = ri;
  if (ri != -1) B.L[ri] = li;
  if (ui != -1) B.D[ui] = di;
  if (di != -1) B.U[di] = ui;
  switch (ch) {
    case 'L':
      if (li == -1) return false;
      tmp = li;
      break;
    case 'R':
      if (ri == -1) return false;
      tmp = ri;
      break;
    case 'U':
      if (ui == -1) return false;
      tmp = ui;
      break;
    case 'D':
      if (di == -1) return false;
      tmp = di;
      break;
    case '.':
      return false;
  }
  return true;
}
inline int solve(int i, int j) {
  int tmp = encodeRC(i, j);
  mycopy();
  int res = 0;
  while (true) {
    char ch = grid[decodeR(tmp)][decodeC(tmp)];
    bool flag = move(ch, tmp);
    if (flag == false) break;
    ++res;
  }
  return res;
}
inline void proc() {
  preprocess();
  int bst = 0;
  int cnt = 0;
  for (int i = 0, j1 = R; i < j1; ++i) {
    for (int j = 0, j1 = C; j < j1; ++j) {
      int local_bst = solve(i, j);
      if (local_bst >= bst) {
        if (local_bst == bst) {
          ++cnt;
        } else {
          cnt = 1;
          bst = local_bst;
        }
      }
    }
  }
  cout << bst + 1 << ' ' << cnt << '\n';
}
int main() {
  int kase = 1;
  for (int i = 0, j1 = kase; i < j1; ++i) {
    read();
    proc();
  }
  return 0;
}
