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;
char **m;
int N, M;
typedef struct chip {
  int l, r, u, d;
} C;
C **o, **p;
int run(int i, int j) {
  if (p[i][j].r != -1) {
    if (p[i][j].l == -1)
      p[i][j + p[i][j].r].l = -1;
    else
      p[i][j + p[i][j].r].l = p[i][j].l + p[i][j].r;
  }
  if (p[i][j].l != -1) {
    if (p[i][j].r == -1)
      p[i][j - p[i][j].l].r = -1;
    else
      p[i][j - p[i][j].l].r = p[i][j].l + p[i][j].r;
  }
  if (p[i][j].d != -1) {
    if (p[i][j].u == -1)
      p[i + p[i][j].d][j].u = -1;
    else
      p[i + p[i][j].d][j].u = p[i][j].u + p[i][j].d;
  }
  if (p[i][j].u != -1) {
    if (p[i][j].d == -1)
      p[i - p[i][j].u][j].d = -1;
    else
      p[i - p[i][j].u][j].d = p[i][j].u + p[i][j].d;
  }
  if (m[i][j] == 'U')
    if (p[i][j].u != -1) return 1 + run(i - p[i][j].u, j);
  if (m[i][j] == 'D')
    if (p[i][j].d != -1) return 1 + run(i + p[i][j].d, j);
  if (m[i][j] == 'L')
    if (p[i][j].l != -1) return 1 + run(i, j - p[i][j].l);
  if (m[i][j] == 'R')
    if (p[i][j].r != -1) return 1 + run(i, j + p[i][j].r);
  return 1;
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &N, &M);
  int i, j, k, l;
  m = (char **)malloc(sizeof(char *) * N);
  for (i = 0; i < N; i++) m[i] = (char *)malloc(sizeof(char) * (M + 1));
  o = (C **)malloc(sizeof(C *) * N);
  for (i = 0; i < N; i++) o[i] = (C *)malloc(sizeof(C) * (M + 1));
  p = (C **)malloc(sizeof(C *) * N);
  for (i = 0; i < N; i++) p[i] = (C *)malloc(sizeof(C) * (M + 1));
  int best = 0, num = 0;
  for (i = 0; i < N; i++) scanf("%s", m[i]);
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++) {
      o[i][j].l = -1;
      o[i][j].r = -1;
      o[i][j].u = -1;
      o[i][j].d = -1;
    }
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++)
      if (m[i][j] != '.') {
        for (k = 1; j - k >= 0; k++)
          if (m[i][j - k] != '.') {
            o[i][j].l = k;
            o[i][j - k].r = k;
            break;
          }
        for (k = 1; i - k >= 0; k++)
          if (m[i - k][j] != '.') {
            o[i][j].u = k;
            o[i - k][j].d = k;
            break;
          }
      }
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++) {
      if (m[i][j] == '.') continue;
      for (k = 0; k < N; k++)
        for (l = 0; l < M; l++) {
          p[k][l].l = o[k][l].l;
          p[k][l].r = o[k][l].r;
          p[k][l].u = o[k][l].u;
          p[k][l].d = o[k][l].d;
        }
      k = run(i, j);
      if (k > best) {
        best = k;
        num = 0;
      }
      if (k == best) num++;
    }
  printf("%d %d\n", best, num);
  return 0;
}
