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>
char** mm;
int n, m;
int **le, **ri, **up, **down;
bool** used;
void init_ar(int** p, int n, int m) {
  p = new int*[n];
  int i;
  for (i = 0; i < n; i++) p[i] = new int[m];
}
void init_next() {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (i == 0 || mm[i - 1][j] != '.')
        up[i][j] = i - 1;
      else
        up[i][j] = up[i - 1][j];
      if (j == 0 || mm[i][j - 1] != '.')
        le[i][j] = j - 1;
      else
        le[i][j] = le[i][j - 1];
    }
  for (i = n - 1; i >= 0; i--)
    for (j = m - 1; j >= 0; j--) {
      if (i == n - 1 || mm[i + 1][j] != '.')
        down[i][j] = i + 1;
      else
        down[i][j] = down[i + 1][j];
      if (j == m - 1 || mm[i][j + 1] != '.')
        ri[i][j] = j + 1;
      else
        ri[i][j] = ri[i][j + 1];
    }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) used[i][j] = 0;
}
bool valid(int y, int x) { return (y >= 0 && y < n && x >= 0 && x < m); }
int get_ver(int** com, int y, int x) {
  if (!valid(y, x)) return y;
  if (!used[y][x]) return y;
  return com[y][x] = get_ver(com, com[y][x], x);
}
int get_hor(int** com, int y, int x) {
  if (!valid(y, x)) return x;
  if (!used[y][x]) return x;
  return com[y][x] = get_hor(com, y, com[y][x]);
}
int proc(int y, int x) {
  init_next();
  int it;
  for (it = 0;; it++) {
    if (!valid(y, x)) break;
    used[y][x] = true;
    if (mm[y][x] == 'D')
      y = get_ver(down, y, x);
    else if (mm[y][x] == 'U')
      y = get_ver(up, y, x);
    else if (mm[y][x] == 'L')
      x = get_hor(le, y, x);
    else if (mm[y][x] == 'R')
      x = get_hor(ri, y, x);
  }
  return it;
}
int main() {
  scanf("%d %d", &n, &m);
  mm = new char*[n];
  le = new int*[n];
  ri = new int*[n];
  up = new int*[n];
  down = new int*[n];
  used = new bool*[n];
  int i, j;
  for (i = 0; i < n; i++) {
    mm[i] = new char[m + 1];
    le[i] = new int[m];
    ri[i] = new int[m];
    up[i] = new int[m];
    down[i] = new int[m];
    used[i] = new bool[m];
  }
  for (i = 0; i < n; i++) scanf("%s", mm[i]);
  int res = 0;
  int nres = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (mm[i][j] != '.') {
        int tmp = proc(i, j);
        if (tmp > res) {
          res = tmp;
          nres = 1;
        } else if (tmp == res) {
          nres++;
        }
      }
  printf("%d %d\n", res, nres);
  return 0;
}
