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;
int n, m;
char od[5010][5010], s[5010][5010], f[5][10010];
int lx[4] = {-1, 0, 1, 0}, ly[4] = {0, 1, 0, -1}, ans, ansi;
int cr[300];
void clr() {
  for (int i = 0; i < n; i++) strcpy(s[i], od[i]);
}
int gf(int fx, int x, int y, int &a, int &b) {
  if (f[fx][x * m + y] == -1) {
    a = -1;
    b = -1;
    return -1;
  }
  int i = f[fx][x * m + y] / m, j = f[fx][x * m + y] % m;
  if (s[i][j] != '.') {
    a = i;
    b = j;
    return i * m + j;
  } else
    return f[fx][x * m + y] = gf(fx, i, j, a, b);
}
void togo(int x, int y) {
  memset(f, -1, sizeof(f));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int fx = 0; fx < 4; fx++) {
        int x = i + lx[fx], y = j + ly[fx];
        if (x >= 0 && x < n && y >= 0 && y < m)
          f[fx][i * m + j] = x * m + y;
        else
          f[fx][i * m + j] = -1;
      }
  int fx = cr[s[x][y]];
  s[x][y] = '.';
  int tmp = 1;
  int i, j;
  while (1) {
    i = x;
    j = y;
    if (gf(fx, i, j, x, y) == -1) break;
    tmp++;
    fx = cr[s[x][y]];
    s[x][y] = '.';
  }
  if (tmp == ans) ansi++;
  if (tmp > ans) {
    ans = tmp;
    ansi = 1;
  }
}
int main() {
  cr['U'] = 0;
  cr['R'] = 1;
  cr['D'] = 2;
  cr['L'] = 3;
  while (~scanf("%d%d", &n, &m)) {
    ans = 1;
    ansi = 0;
    for (int i = 0; i < n; i++) scanf("%s", od[i]);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (od[i][j] != '.') {
          clr();
          togo(i, j);
        }
    printf("%d %d\n", ans, ansi);
  }
  return 0;
}
