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>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e18;
char mode[100][5002];
short int cup[4][100][5002];
short int up[4][100][5002];
int best = 0, cnt = 0;
inline int geti(int type, int x, int y) {
  if (up[type][x][y] == -1 || (type >= 2 && up[type][x][y] == x) ||
      (type < 2 && up[type][x][y] == y))
    return up[type][x][y];
  int nex = up[type][x][y];
  if (type >= 2) return up[type][x][y] = geti(type, nex, y);
  return up[type][x][y] = geti(type, x, nex);
}
inline void upd(int x, int y) {
  for (int i = 0; i < 2; i++) {
    int plus = (!i ? -1 : 1);
    up[i][x][y] = y + plus;
  }
  for (int i = 0; i < 2; i++) {
    int plus = (!i ? -1 : 1);
    up[i + 2][x][y] = x + plus;
  }
}
int n, m;
int dfs(int i, int j) {
  char c = mode[i][j];
  upd(i, j);
  int out = 1;
  if (c == 'L') {
    int nex = geti(0, i, j);
    if (nex != -1 && nex < m) out = dfs(i, nex) + 1;
  }
  if (c == 'R') {
    int nex = geti(1, i, j);
    if (nex != -1 && nex < m) out = dfs(i, nex) + 1;
  }
  if (c == 'U') {
    int nex = geti(2, i, j);
    if (nex != -1 && nex < n) out = dfs(nex, j) + 1;
  }
  if (c == 'D') {
    int nex = geti(3, i, j);
    if (nex != -1 && nex < n) out = dfs(nex, j) + 1;
  }
  if (out > best) {
    best = out;
    cnt = 0;
  }
  if (out == best) cnt++;
  return out;
}
int main() {
  cin >> n >> m;
  char c;
  scanf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &c);
      if (n < m)
        mode[i][j] = c;
      else {
        if (c == 'U')
          c = 'R';
        else if (c == 'R')
          c = 'D';
        else if (c == 'D')
          c = 'L';
        else if (c != '.')
          c = 'U';
        mode[j][n - 1 - i] = c;
      }
      if (c == '.') continue;
    }
    scanf("\n");
  }
  if (n >= m) swap(n, m);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      cup[1][i][j] = m;
      cup[3][i][j] = n;
    }
  }
  vector<int> pre(m, -1);
  for (int i = 0; i < n; i++) {
    int pp = -1;
    for (int j = 0; j < m; j++) {
      if (mode[i][j] != '.') {
        pre[j] = i;
        pp = j;
      }
      cup[0][i][j] = pp;
      cup[2][i][j] = pre[j];
    }
  }
  pre.assign(m, n);
  for (int i = n - 1; i >= 0; i--) {
    int pp = m;
    for (int j = m - 1; j >= 0; j--) {
      if (mode[i][j] != '.') {
        pre[j] = i;
        pp = j;
      }
      cup[1][i][j] = pp;
      cup[3][i][j] = pre[j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) {
        for (int i2 = 0; i2 <= n; i2++) {
          for (int j2 = 0; j2 <= m; j2++) {
            up[k][i2][j2] = cup[k][i2][j2];
          }
        }
      }
      if (mode[i][j] != '.') dfs(i, j);
    }
  }
  cout << best << " " << cnt;
}
