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 = 1e9;
const int MOD = 1e9 + 7;
const int N = 5e3 + 10;
const string dir = "LDUR";
const int dx[4] = {0, 1, -1, 0}, dy[4] = {-1, 0, 0, 1};
int a[N][N] = {0}, n, m, Slink[N][4], link[N][4];
char s[N];
int cv(char x) {
  int ans = 3;
  while (ans >= 0 && dir[ans] != x) ans--;
  return ans;
}
bool inside(pair<int, int> x) {
  return (x.first > 0 && x.first <= n && x.second > 0 && x.second <= m);
}
int check(pair<int, int> cur) {
  for (auto i = 0; i < n * m; i++)
    for (auto k = 0; k <= 3; k++) link[i][k] = Slink[i][k];
  int ans = 0, idx = (cur.first - 1) * m + cur.second - 1;
  while (1) {
    ans++;
    for (auto i = 0; i <= 3; i++) {
      int nidx = link[idx][i];
      if (nidx == -1) continue;
      link[nidx][3 - i] = link[idx][3 - i];
    }
    int cx = idx / m + 1, cy = idx % m + 1;
    idx = link[idx][a[cx][cy]];
    if (idx == -1) break;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (auto i = 1; i <= n; i++) {
    scanf("\n%s", s);
    for (auto j = 1; j <= m; j++) a[i][j] = cv(s[j - 1]);
  }
  for (auto i = 1; i <= n; i++)
    for (auto j = 1; j <= m; j++)
      if (a[i][j] != -1) {
        for (auto k = 0; k <= 3; k++) {
          int cx = i + dx[k], cy = j + dy[k];
          while (a[cx][cy] == -1) cx += dx[k], cy += dy[k];
          Slink[(i - 1) * m + j - 1][k] =
              inside(pair<int, int>(cx, cy)) ? ((cx - 1) * m + cy - 1) : -1;
        }
      }
  int ans = 0, way = 0;
  for (auto i = 1; i <= n; i++)
    for (auto j = 1; j <= m; j++)
      if (a[i][j] != -1) {
        int v = check(pair<int, int>(i, j));
        if (v > ans)
          ans = v, way = 1;
        else if (v == ans)
          way++;
      }
  cout << ans << " " << way;
}
