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 = 5050;
short nd[N][N], nu[N][N], nl[N][N], nr[N][N];
bool was[N][N];
char field[N][N];
int n, m;
int last;
short order[N][2], cntOrd;
inline void del(int x, int y) {
  if (nu[x][y] != -1) nd[nu[x][y]][y] = nd[x][y];
  if (nd[x][y] != -1) nu[nd[x][y]][y] = nu[x][y];
  if (nl[x][y] != -1) nr[x][nl[x][y]] = nr[x][y];
  if (nr[x][y] != -1) nl[x][nr[x][y]] = nl[x][y];
}
inline void recover(int x, int y) {
  if (nu[x][y] != -1) nd[nu[x][y]][y] = x;
  if (nd[x][y] != -1) nu[nd[x][y]][y] = x;
  if (nl[x][y] != -1) nr[x][nl[x][y]] = y;
  if (nr[x][y] != -1) nl[x][nr[x][y]] = y;
}
int getInt(char delim) {
  int ret = 0;
  char c;
  while ((c = getchar()) != delim) ret = ret * 10 + c - '0';
  return ret;
}
int main() {
  n = getInt(' ');
  m = getInt('\n');
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      field[i][j] = getchar();
    }
    getchar();
    last = -1;
    for (int j = 0; j < m; j++)
      if (field[i][j] != '.') {
        nl[i][j] = last;
        last = j;
      }
    last = -1;
    for (int j = m - 1; j >= 0; j--)
      if (field[i][j] != '.') {
        nr[i][j] = last;
        last = j;
      }
  }
  for (int j = 0; j < m; j++) {
    last = -1;
    for (int i = 0; i < n; i++)
      if (field[i][j] != '.') {
        nu[i][j] = last;
        last = i;
      }
    last = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (field[i][j] != '.') {
        nd[i][j] = last;
        last = i;
      }
    }
  }
  int maxAns = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (field[i][j] != '.') {
        int cur = 1;
        int x = i, y = j;
        int nx = x, ny = y;
        cntOrd = 0;
        const char cmd = field[i][j];
        while (true) {
          if (cmd == 'L')
            ny = nl[nx][ny];
          else if (cmd == 'R')
            ny = nr[nx][ny];
          else if (cmd == 'U')
            nx = nu[nx][ny];
          else
            nx = nd[nx][ny];
          if (nx == -1 or ny == -1) break;
          del(x, y);
          order[cntOrd][0] = x;
          order[cntOrd++][1] = y;
          cur++;
          x = nx;
          y = ny;
        }
        for (int k = 0; k < cntOrd; k++) recover(order[k][0], order[k][1]);
        if (cur > maxAns) {
          maxAns = cur;
          cnt = 1;
        } else if (cur == maxAns)
          cnt++;
      }
  }
  printf("%d %d\n", maxAns, cnt);
  return 0;
}
