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>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double PI = 2 * acos(0.0);
const double EPS = 1e-8;
const int INF = 1000000000;
int m, n, ans, cr, ca;
char s[5000][5001], ss[5000][5001];
int f[5000][5000];
vector<short> du[5000], dd[5000], dl[5000], dr[5000];
int fun(int r, int c) {
  int rr = r, cc = c;
  int res = 0;
  while (true) {
    cr = rr;
    ca = cc;
    char k = s[rr][cc];
    ++res;
    s[rr][cc] = '.';
    if (k == 'U') {
      while (rr >= 0 && s[rr][cc] == '.') rr -= du[rr][cc];
      du[cr][ca] = cr - rr;
      if (rr < 0) return res;
    } else if (k == 'D') {
      while (rr < m && s[rr][cc] == '.') rr += dd[rr][cc];
      dd[cr][ca] = rr - cr;
      if (rr >= m) return res;
    } else if (k == 'L') {
      while (cc >= 0 && s[rr][cc] == '.') cc -= dl[rr][cc];
      dl[cr][ca] = ca - cc;
      if (cc < 0) return res;
    } else if (k == 'R') {
      while (cc < n && s[rr][cc] == '.') cc += dr[rr][cc];
      dr[cr][ca] = cc - ca;
      if (cc >= n) return res;
    };
  };
  return 0;
};
int main() {
  scanf("%d%d\n", &m, &n);
  for (int ii = 0; ii < m; ++ii) {
    du[ii].assign(1, n);
    dl[ii].assign(1, n);
    dd[ii].assign(1, n);
    dr[ii].assign(1, n);
  };
  for (int i = 0; i < m; ++i) gets(ss[i]);
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) f[i][j] = -1;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j)
      if (ss[i][j] != '.') {
        for (int ii = 0; ii < m; ++ii) {
          du[ii].assign(n, 1);
          dl[ii].assign(n, 1);
          dd[ii].assign(n, 1);
          dr[ii].assign(n, 1);
        };
        for (int ii = 0; ii < m; ++ii)
          for (int jj = 0; jj < n; ++jj) {
            s[ii][jj] = ss[ii][jj];
          };
        f[i][j] = fun(i, j);
        ans = max(ans, f[i][j]);
      };
  int cnt = 0;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j)
      if (f[i][j] == ans) ++cnt;
  cout << ans << " " << cnt;
  return 0;
};
