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<char> a[5001];
vector<int> usl[5011], usr[5011], usd[5011], usu[5011];
vector<int> l[5011], r[5011], d[5011], u[5011];
int n, m;
int dfs(int i, int j, int kol) {
  if (i == 0 || i == n + 1 || j == 0 || j == m + 1) return kol - 1;
  int tt;
  int x, y, z, w;
  x = l[i][j];
  y = r[i][j];
  z = u[i][j];
  w = d[i][j];
  if (x != 0 && x != m + 1) r[i][x] = y;
  if (y != 0 && y != m + 1) l[i][y] = x;
  if (z != 0 && z != n + 1) d[z][j] = w;
  if (w != 0 && w != n + 1) u[w][j] = z;
  int el;
  if (a[i][j] == 'D')
    return dfs(d[i][j], j, kol + 1);
  else if (a[i][j] == 'U')
    return dfs(u[i][j], j, kol + 1);
  else if (a[i][j] == 'L')
    return dfs(i, l[i][j], kol + 1);
  else
    return dfs(i, r[i][j], kol + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, j, nom;
  char x;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m + 3; j++)
      a[i].push_back(0), usl[i].push_back(0), usr[i].push_back(0),
          usu[i].push_back(0), usd[i].push_back(0);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m + 1; j++)
      l[i].push_back(0), r[i].push_back(0), u[i].push_back(0),
          d[i].push_back(0);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> x, a[i][j] = x;
  for (i = 1; i <= n; i++) {
    nom = 0;
    for (j = 1; j <= m; j++) {
      usl[i][j] = nom;
      if (a[i][j] != '.') nom = j;
    }
  }
  for (i = 1; i <= n; i++) {
    nom = m + 1;
    for (j = m; j >= 1; j--) {
      usr[i][j] = nom;
      if (a[i][j] != '.') nom = j;
    }
  }
  for (i = 1; i <= m; i++) {
    nom = 0;
    for (j = 1; j <= n; j++) {
      usu[j][i] = nom;
      if (a[j][i] != '.') nom = j;
    }
  }
  for (i = 1; i <= m; i++) {
    nom = n + 1;
    for (j = n; j >= 1; j--) {
      usd[j][i] = nom;
      if (a[j][i] != '.') nom = j;
    }
  }
  for (int i1 = 1; i1 <= n; i1++)
    for (int j1 = 1; j1 <= m; j1++)
      l[i1][j1] = usl[i1][j1], r[i1][j1] = usr[i1][j1], u[i1][j1] = usu[i1][j1],
      d[i1][j1] = usd[i1][j1];
  int mx = 0, xr = 0, kol = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == '.') continue;
      for (int i1 = 1; i1 <= n; i1++)
        for (int j1 = 1; j1 <= m; j1++)
          l[i1][j1] = usl[i1][j1], r[i1][j1] = usr[i1][j1],
          u[i1][j1] = usu[i1][j1], d[i1][j1] = usd[i1][j1];
      xr = dfs(i, j, 1);
      if (xr > mx) mx = xr, kol = 0;
      if (xr == mx) kol++;
    }
  }
  cout << mx << ' ' << kol << '\n';
}
