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;
vector<int> adj[5010][4];
vector<int> adj1[5010][4];
int n, m;
char grid[5050];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
void ini() {
  int i, j, k, li, lj;
  for (i = 0; i < 5001; i++)
    for (j = 0; j < 4; j++) adj[i][j].clear();
  for (i = 0; i < n; i++) {
    lj = -1;
    for (j = 0; j < m; j++) {
      if (grid[i * m + j] != '.') {
        if (lj != -1) {
          adj[i * m + j][0].push_back(i * m + lj);
          adj[i * m + lj][1].push_back(i * m + j);
        }
        lj = j;
      }
    }
  }
  for (j = 0; j < m; j++) {
    li = -1;
    for (i = 0; i < n; i++) {
      if (grid[i * m + j] != '.') {
        if (li != -1) {
          adj[i * m + j][2].push_back(li * m + j);
          adj[li * m + j][3].push_back(i * m + j);
        }
        li = i;
      }
    }
  }
}
void ini2() {
  int i, j, k;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      for (k = 0; k < 4; k++) {
        adj1[i * m + j][k] = adj[i * m + j][k];
      }
    }
}
int get(int f) {
  int i, j, ret = 0, k, lo, hi, mid, u, v;
  ini2();
  while (1) {
    if (f != -1) {
      if (adj1[f][0].size())
        u = adj1[f][0][0];
      else
        u = -1;
      if (adj1[f][1].size())
        v = adj1[f][1][0];
      else
        v = -1;
      if (u != -1 && v != -1) {
        adj1[u][1][0] = v;
        adj1[v][0][0] = u;
      } else {
        if (u != -1) adj1[u][1].clear();
        if (v != -1) adj1[v][0].clear();
      }
      if (adj1[f][2].size())
        u = adj1[f][2][0];
      else
        u = -1;
      if (adj1[f][3].size())
        v = adj1[f][3][0];
      else
        v = -1;
      if (u != -1 && v != -1) {
        adj1[u][3][0] = v;
        adj1[v][2][0] = u;
      } else {
        if (u != -1) adj1[u][3].clear();
        if (v != -1) adj1[v][2].clear();
      }
      if (grid[f] == 'L') {
        if (adj1[f][0].size())
          f = adj1[f][0][0];
        else
          f = -1;
      } else if (grid[f] == 'R') {
        if (adj1[f][1].size())
          f = adj1[f][1][0];
        else
          f = -1;
      } else if (grid[f] == 'U') {
        if (adj1[f][2].size())
          f = adj1[f][2][0];
        else
          f = -1;
      } else if (grid[f] == 'D') {
        if (adj1[f][3].size())
          f = adj1[f][3][0];
        else
          f = -1;
      }
      ret++;
    } else {
      break;
    }
  }
  return ret;
}
int main() {
  int i, j;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", grid + i * m);
  ini();
  int mx = 0, l;
  int cnt = 0, now, x;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (grid[i * m + j] == '.') continue;
      now = get(i * m + j);
      if (now > mx) {
        mx = now;
        cnt = 1;
      } else if (now == mx)
        cnt++;
    }
  printf("%d %d\n", mx, cnt);
  return 0;
}
