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;
const int inf(1010101010);
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, 1, 0, -1};
int h, w;
vector<vector<int> > a;
vector<vector<int> > rowpred, rowsucc;
vector<vector<int> > colpred, colsucc;
int ii[5005], jj[5005];
inline void dorm(int y, int x) {
  int rpred(rowpred[y][x]), rsucc(rowsucc[y][x]);
  if (rpred != -1) rowsucc[y][rpred] = rsucc;
  if (rsucc != -1) rowpred[y][rsucc] = rpred;
  int cpred(colpred[x][y]), csucc(colsucc[x][y]);
  if (cpred != -1) colsucc[x][cpred] = csucc;
  if (csucc != -1) colpred[x][csucc] = cpred;
}
int sim(int y0, int x0) {
  for (int i(0); i < (h); i++) {
    int nj(0);
    for (int j(0); j < (w); j++)
      if (a[i][j] >= 0) jj[nj++] = j;
    if (nj == 0) continue;
    rowpred[i][jj[0]] = rowsucc[i][jj[nj - 1]] = -1;
    for (int k(0); k < (nj - 1); k++)
      rowpred[i][jj[k + 1]] = jj[k], rowsucc[i][jj[k]] = jj[k + 1];
  }
  for (int j(0); j < (w); j++) {
    int ni(0);
    for (int i(0); i < (h); i++)
      if (a[i][j] >= 0) ii[ni++] = i;
    if (ni == 0) continue;
    colpred[j][ii[0]] = colsucc[j][ii[ni - 1]] = -1;
    for (int k(0); k < (ni - 1); k++)
      colpred[j][ii[k + 1]] = ii[k], colsucc[j][ii[k]] = ii[k + 1];
  }
  int cnt(0);
  for (int y(y0), x(x0);;) {
    cnt++;
    int d(a[y][x]);
    int yy, xx;
    if (d == 0) {
      if (colpred[x][y] == -1) goto klaar;
      yy = colpred[x][y], xx = x;
    } else if (d == 2) {
      if (colsucc[x][y] == -1) goto klaar;
      yy = colsucc[x][y], xx = x;
    } else if (d == 3) {
      if (rowpred[y][x] == -1) goto klaar;
      yy = y, xx = rowpred[y][x];
    } else if (d == 1) {
      if (rowsucc[y][x] == -1) goto klaar;
      yy = y, xx = rowsucc[y][x];
    }
    dorm(y, x);
    y = yy, x = xx;
  }
klaar:;
  return cnt;
}
int main() {
  cin >> h >> w;
  a.resize(h);
  for (int i(0); i < (h); i++) {
    a[i].resize(w);
    string s;
    cin >> s;
    for (int j(0); j < (w); j++) {
      char c(s[j]);
      int& r(a[i][j]);
      if (c == 'U')
        r = 0;
      else if (c == 'R')
        r = 1;
      else if (c == 'D')
        r = 2;
      else if (c == 'L')
        r = 3;
      else
        r = -1;
    }
  }
  colpred = vector<vector<int> >(w, vector<int>(h));
  colsucc = vector<vector<int> >(w, vector<int>(h));
  rowpred = vector<vector<int> >(h, vector<int>(w));
  rowsucc = vector<vector<int> >(h, vector<int>(w));
  int mx(0), cnt(0);
  for (int i(0); i < (h); i++)
    for (int j(0); j < (w); j++)
      if (a[i][j] >= 0) {
        int re(sim(i, j));
        if (re > mx)
          mx = re, cnt = 1;
        else if (re == mx)
          cnt++;
      }
  cout << mx << " " << cnt << endl;
}
