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;
vector<vector<char> > g;
int n, m;
vector<vector<int> > nxtcol1, prvcol1, nxtrow1, prvrow1;
inline int solve(int r, int c) {
  int ret = 0;
  while (true) {
    if (r >= n || c >= m) break;
    ret++;
    int i = r, j = c;
    if (g[r][c] == 'L') {
      c = prvcol1[r][j];
      nxtcol1[r][c] = nxtcol1[r][j];
      prvcol1[r][nxtcol1[r][j]] = c;
      nxtrow1[prvrow1[r][j]][j] = nxtrow1[r][j];
      prvrow1[nxtrow1[r][j]][j] = prvrow1[r][j];
    } else if (g[r][c] == 'R') {
      c = nxtcol1[r][j];
      prvcol1[r][c] = prvcol1[r][j];
      nxtcol1[r][prvcol1[r][j]] = c;
      nxtrow1[prvrow1[r][j]][j] = nxtrow1[r][j];
      prvrow1[nxtrow1[r][j]][j] = prvrow1[r][j];
    } else if (g[r][c] == 'U') {
      r = prvrow1[r][c];
      nxtrow1[r][c] = nxtrow1[i][c];
      prvrow1[nxtrow1[i][c]][c] = r;
      nxtcol1[i][prvcol1[i][c]] = nxtcol1[i][c];
      prvcol1[i][nxtcol1[i][c]] = prvcol1[i][c];
    } else if (g[r][c] == 'D') {
      r = nxtrow1[r][c];
      prvrow1[r][c] = prvrow1[i][c];
      nxtrow1[prvrow1[i][c]][c] = r;
      nxtcol1[i][prvcol1[i][c]] = nxtcol1[i][c];
      prvcol1[i][nxtcol1[i][c]] = prvcol1[i][c];
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  g.resize(n + 5);
  vector<vector<int> > nxtcol(n + 5, vector<int>(m + 5));
  vector<vector<int> > prvcol(n + 5, vector<int>(m + 5));
  vector<vector<int> > nxtrow(n + 5, vector<int>(m + 5));
  vector<vector<int> > prvrow(n + 5, vector<int>(m + 5));
  for (int i = 0; i < n; i++) {
    g[i].resize(m + 5);
    for (int j = 0; j < m; j++) cin >> g[i][j];
  }
  for (int i = 0; i < n; i++) {
    int last = m;
    for (int j = m - 1; j >= 0; j--) {
      if (g[i][j] != '.') {
        nxtcol[i][j] = last;
        prvcol[i][last] = j;
        last = j;
      }
    }
    prvcol[i][last] = m + 1;
  }
  for (int i = 0; i < m; i++) {
    int last = n;
    for (int j = n - 1; j >= 0; j--) {
      if (g[j][i] != '.') {
        nxtrow[j][i] = last;
        prvrow[last][i] = j;
        last = j;
      }
    }
    prvrow[last][i] = n + 1;
  }
  int ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] != '.') {
        nxtcol1 = nxtcol;
        prvcol1 = prvcol;
        nxtrow1 = nxtrow;
        prvrow1 = prvrow;
        int temp = solve(i, j);
        if (ans < temp)
          ans = temp, cnt = 1;
        else if (ans == temp)
          cnt++;
      }
    }
  }
  cout << ans << " " << cnt << endl;
  return 0;
}
