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 maxn = 5000 + 5;
short dir[4][maxn][maxn];
int h, w;
char mat[maxn][maxn];
void init() {
  for (int i = 0; i < h; ++i) {
    dir[1][i][0] = -1;
    for (int j = 1; j < w; ++j) dir[1][i][j] = j - 1;
    dir[3][i][w - 1] = -1;
    for (int j = w - 2; j >= 0; --j) dir[3][i][j] = j + 1;
  }
  for (int i = 0; i < w; ++i) {
    dir[2][0][i] = -1;
    for (int j = 1; j < w; ++j) dir[2][j][i] = j - 1;
    dir[0][h - 1][i] = -1;
    for (int j = h - 2; j >= 0; --j) dir[0][j][i] = j + 1;
  }
}
int d[][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
struct dat {
  int r, c, d;
  dat(){};
  dat(int p1, int p2, int p3) : r(p1), c(p2), d(p3){};
};
int main() {
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    scanf("%s", mat[i]);
    for (int j = 0; j < w; ++j) {
      if (mat[i][j] == '.')
        mat[i][j] = -1;
      else if (mat[i][j] == 'D')
        mat[i][j] = 0;
      else if (mat[i][j] == 'L')
        mat[i][j] = 1;
      else if (mat[i][j] == 'U')
        mat[i][j] = 2;
      else
        mat[i][j] = 3;
    }
  }
  int mx = 0, cn = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (mat[i][j] == -1) continue;
      printf("%d %d\n", i, j);
      for (int r = 0; r < h; ++r)
        for (int c = 0; c < w; ++c)
          dir[0][r][c] = dir[1][r][c] = dir[2][r][c] = dir[3][r][c] = 0;
      init();
      int cnt = 0;
      int r = i, c = j, d = mat[r][c];
      while (r != -1 && c != -1) {
        int left = dir[1][r][c];
        int right = dir[3][r][c];
        if (left != -1) dir[3][r][left] = right;
        if (right != -1) dir[1][r][right] = left;
        int down = dir[0][r][c];
        int up = dir[2][r][c];
        if (up != -1) dir[0][up][c] = down;
        if (down != -1) dir[2][down][c] = up;
        if (mat[r][c] != -1) d = mat[r][c], cnt++;
        if (d == 0 || d == 2)
          r = dir[d][r][c];
        else
          c = dir[d][r][c];
      }
      if (cnt > mx)
        mx = cnt, cn = 1;
      else if (cnt == mx)
        cn++;
    }
  }
  printf("%d %d\n", mx, cn);
  return 0;
}
