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;
typedef struct pointers_ {
  int U, D, R, L;
} pointers;
int r, c;
char m[5010][5010];
pointers* p[5010];
pointers memory[5010];
int pp;
pointers* pmalloc() {
  pointers* point = memory + pp;
  pp += c;
  return point;
}
int run(int i, int j) {
  char old = m[i][j];
  int x = i;
  int y = j;
  switch (m[i][j]) {
    case 'U':
      x = p[x][y].U;
      break;
    case 'D':
      x = p[x][y].D;
      break;
    case 'R':
      y = p[x][y].R;
      break;
    case 'L':
      y = p[x][y].L;
      break;
  }
  m[i][j] = '.';
  int run2 = 0;
  if (x >= 0 and x < r and y >= 0 and y < c) {
    if (p[i][j].L >= 0 and p[i][j].L < c) p[i][p[i][j].L].R = p[i][j].R;
    if (p[i][j].R >= 0 and p[i][j].R < c) p[i][p[i][j].R].L = p[i][j].L;
    if (p[i][j].D >= 0 and p[i][j].D < r) p[p[i][j].D][j].U = p[i][j].U;
    if (p[i][j].U >= 0 and p[i][j].U < r) p[p[i][j].U][j].D = p[i][j].D;
    run2 = run(x, y);
    if (p[i][j].L >= 0 and p[i][j].L < c) p[i][p[i][j].L].R = j;
    if (p[i][j].R >= 0 and p[i][j].R < c) p[i][p[i][j].R].L = j;
    if (p[i][j].D >= 0 and p[i][j].D < r) p[p[i][j].D][j].U = i;
    if (p[i][j].U >= 0 and p[i][j].U < r) p[p[i][j].U][j].D = i;
  }
  m[i][j] = old;
  return 1 + run2;
}
void populate(int i, int j) {
  if (m[i][j] == '.') return;
  int k;
  for (k = i + 1; k < r; k++)
    if (m[k][j] != '.') {
      p[i][j].D = k;
      break;
    }
  if (k == r) p[i][j].D = 0x3f3f3f3f;
  for (k = i - 1; k >= 0; k--)
    if (m[k][j] != '.') {
      p[i][j].U = k;
      break;
    }
  if (k < 0) p[i][j].U = -1;
  for (k = j + 1; k < c; k++)
    if (m[i][k] != '.') {
      p[i][j].R = k;
      break;
    }
  if (k == c) p[i][j].R = 0x3f3f3f3f;
  for (k = j - 1; k >= 0; k--)
    if (m[i][k] != '.') {
      p[i][j].L = k;
      break;
    }
  if (k < 0) p[i][j].L = -1;
  return;
}
int main() {
  scanf("%d %d", &r, &c);
  for (int i = 0; i < r; i++) scanf("%s", m[i]);
  pp = 0;
  for (int i = 0; i < r; i++) p[i] = pmalloc();
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) populate(i, j);
  int maior = 0;
  int qnts = 0;
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      if (m[i][j] != '.') {
        int res = run(i, j);
        if (res > maior) {
          maior = res;
          qnts = 1;
        } else if (res == maior)
          qnts++;
      }
  printf("%d %d\n", maior, qnts);
  return 0;
}
