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;
char mp[5005][5005];
int n, m, t, nr;
int L[5005 << 1], R[5005 << 1], U[5005 << 1], D[5005 << 1];
void init() {
  for (int i = t; i < t + n; i++) L[i] = R[i] = i;
  for (int i = t; i < t + m; i++) U[i] = D[i] = i;
}
void remove(int idx) {
  U[D[idx]] = U[idx];
  D[U[idx]] = D[idx];
  L[R[idx]] = L[idx];
  R[L[idx]] = R[idx];
}
void resume(int idx) {
  D[U[idx]] = U[D[idx]] = idx;
  L[R[idx]] = R[L[idx]] = idx;
}
void solve(int i, int j, int d) {
  int idx = i * m + j;
  remove(idx);
  if (mp[i][j] == 'L') {
    if (L[idx] == i + t)
      nr = (nr > d + 1 ? nr : d + 1);
    else
      solve(L[idx] / m, L[idx] % m, d + 1);
  } else if (mp[i][j] == 'R') {
    if (R[idx] == i + t)
      nr = (nr > d + 1 ? nr : d + 1);
    else
      solve(R[idx] / m, R[idx] % m, d + 1);
  } else if (mp[i][j] == 'U') {
    if (U[idx] == j + t)
      nr = (nr > d + 1 ? nr : d + 1);
    else
      solve(U[idx] / m, U[idx] % m, d + 1);
  } else if (mp[i][j] == 'D') {
    if (D[idx] == j + t)
      nr = (nr > d + 1 ? nr : d + 1);
    else
      solve(D[idx] / m, D[idx] % m, d + 1);
  }
  resume(idx);
}
int main() {
  int ne, me, idx, res, cnt;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i < n; i++) scanf(" %s", mp[i]);
    t = n * m;
    res = -1;
    cnt = 1;
    init();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mp[i][j] == '.') continue;
        ne = j + t, me = i + t;
        idx = i * m + j;
        U[idx] = U[ne];
        D[idx] = ne;
        D[U[idx]] = idx;
        U[ne] = idx;
        L[idx] = L[me];
        R[idx] = me;
        R[L[idx]] = idx;
        L[me] = idx;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mp[i][j] == '.') continue;
        nr = 0;
        solve(i, j, 0);
        if (nr == res) {
          cnt++;
        } else if (nr > res) {
          res = nr;
          cnt = 1;
        }
      }
    }
    printf("%d %d\n", res, cnt);
  }
  return 0;
}
