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 N = 5010;
int n, m;
vector<string> grid;
vector<vector<int> > l, r, u, d;
bool active[N];
int getpar(vector<vector<int> > &arr, int x, int y) {
  int nxt = arr[x][y];
  if (nxt == N - 1 || active[nxt]) return nxt;
  return arr[x][y] = getpar(arr, nxt / m, nxt % m);
}
int solve(int x, int y) {
  fill(active, active + N - 1, true);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') active[i * m + j] = false;
      l[i][j] = i * m + j - 1;
      r[i][j] = i * m + j + 1;
      u[i][j] = i * m + j - m;
      d[i][j] = i * m + j + m;
      if (i == 0) u[i][j] = N - 1;
      if (i == n - 1) d[i][j] = N - 1;
      if (j == 0) l[i][j] = N - 1;
      if (j == m - 1) r[i][j] = N - 1;
    }
  int ans = 1;
  while (true) {
    int nxt = N - 1;
    if (grid[x][y] == 'L') {
      nxt = getpar(l, x, y);
    }
    if (grid[x][y] == 'R') {
      nxt = getpar(r, x, y);
    }
    if (grid[x][y] == 'U') {
      nxt = getpar(u, x, y);
    }
    if (grid[x][y] == 'D') {
      nxt = getpar(d, x, y);
    }
    if (nxt == N - 1) return ans;
    active[x * m + y] = false;
    x = nxt / m;
    y = nxt % m;
    ++ans;
  }
}
int main() {
  cin >> n >> m;
  l = vector<vector<int> >(n, vector<int>(m));
  r = vector<vector<int> >(n, vector<int>(m));
  u = vector<vector<int> >(n, vector<int>(m));
  d = vector<vector<int> >(n, vector<int>(m));
  grid.resize(n);
  for (int i = 0; i < n; ++i) cin >> grid[i];
  vector<int> res;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      res.push_back(solve(i, j));
    }
  sort(res.rbegin(), res.rend());
  int i = 0;
  while (res[i] == res[0]) ++i;
  cout << res[0] << ' ' << i << '\n';
}
