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 dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int n, m;
char tbl[5010][5010];
int dir[5010][5010];
int lnk[5010][4];
int h(int x, int y) { return x * m + y + 1; }
int cal_x(int p) { return (p - 1) / m; }
int cal_y(int p) { return (p - 1) % m; }
bool valid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
void del(int x, int y) {
  for (int i = 0; i < 4; i++) {
    lnk[lnk[h(x, y)][i]][i ^ 1] = lnk[h(x, y)][i ^ 1];
  }
}
void add(int x, int y) {
  for (int i = 0; i < 4; i++) {
    lnk[lnk[h(x, y)][i]][i ^ 1] = h(x, y);
  }
}
int go(int p) {
  if (p == 0) return 0;
  int x = cal_x(p);
  int y = cal_y(p);
  int d = dir[x][y];
  if (d == -1) return 0;
  del(x, y);
  int ret = go(lnk[h(x, y)][d]) + 1;
  add(x, y);
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", tbl[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      dir[i][j] = -1;
      if (tbl[i][j] == 'U') dir[i][j] = 0;
      if (tbl[i][j] == 'D') dir[i][j] = 1;
      if (tbl[i][j] == 'L') dir[i][j] = 2;
      if (tbl[i][j] == 'R') dir[i][j] = 3;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) {
        int nx = i + dx[k];
        int ny = j + dy[k];
        if (!valid(nx, ny)) continue;
        lnk[h(i, j)][k] = h(nx, ny);
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (dir[i][j] == -1) del(i, j);
  int ans = -1, cnt = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (dir[i][j] == -1) continue;
      int now = go(h(i, j));
      if (now > ans) {
        ans = now;
        cnt = 1;
      } else if (now == ans)
        cnt++;
    }
  printf("%d %d\n", ans, cnt);
  return 0;
}
