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;
template <class stl>
void DBGSTL(stl a) {
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++) {
    cerr << *i << " ";
  }
  cerr << "\n";
  return;
}
struct node {
  pair<int, int> now, up, down, left, right;
};
int n, m;
vector<node> point[5005];
vector<char> grid[5005];
void change(pair<int, int> now) {
  node n = point[now.first][now.second];
  point[n.left.first][n.left.second].right = n.right;
  point[n.right.first][n.right.second].left = n.left;
  point[n.up.first][n.up.second].down = n.down;
  point[n.down.first][n.down.second].up = n.up;
  return;
}
void undo(node n, node u, node d, node l, node r) {
  point[n.now.first][n.now.second] = n;
  point[u.now.first][u.now.second] = u;
  point[d.now.first][d.now.second] = d;
  point[l.now.first][l.now.second] = l;
  point[r.now.first][r.now.second] = r;
  return;
}
pair<int, int> dead = pair<int, int>(0, 0);
pair<int, int> prnt;
int dfs(pair<int, int> now) {
  int ret = 0;
  if (grid[now.first][now.second] == 'U') {
    node n = point[now.first][now.second];
    if (n.up == dead) {
      return 0;
    }
    node u = point[n.up.first][n.up.second];
    node d = point[n.down.first][n.down.second];
    node r = point[n.right.first][n.right.second];
    node l = point[n.left.first][n.left.second];
    change(now);
    ret = 1 + dfs(n.up);
    undo(n, u, d, l, r);
  }
  if (grid[now.first][now.second] == 'D') {
    node n = point[now.first][now.second];
    if (n.down == dead) {
      return 0;
    }
    node u = point[n.up.first][n.up.second];
    node d = point[n.down.first][n.down.second];
    node r = point[n.right.first][n.right.second];
    node l = point[n.left.first][n.left.second];
    change(now);
    ret = 1 + dfs(n.down);
    undo(n, u, d, l, r);
  }
  if (grid[now.first][now.second] == 'L') {
    node n = point[now.first][now.second];
    if (n.left == dead) {
      return 0;
    }
    node u = point[n.up.first][n.up.second];
    node d = point[n.down.first][n.down.second];
    node r = point[n.right.first][n.right.second];
    node l = point[n.left.first][n.left.second];
    change(now);
    ret = 1 + dfs(n.left);
    undo(n, u, d, l, r);
  }
  if (grid[now.first][now.second] == 'R') {
    node n = point[now.first][now.second];
    if (n.right == dead) {
      return 0;
    }
    node u = point[n.up.first][n.up.second];
    node d = point[n.down.first][n.down.second];
    node r = point[n.right.first][n.right.second];
    node l = point[n.left.first][n.left.second];
    change(now);
    ret = 1 + dfs(n.right);
    undo(n, u, d, l, r);
  }
  return ret;
}
int cnt[5005];
char str[5005];
int main() {
  node dummy;
  dummy.down = dummy.left = dummy.right = dummy.up = dummy.now =
      pair<int, int>(0, 0);
  scanf("%d %d", &n, &m);
  for (int i = 0; i <= m; i++) {
    point[0].push_back(dummy);
    grid[0].push_back('.');
  }
  for (int i = 1; i <= n; i++) {
    scanf(" %s", str);
    point[i].push_back(dummy);
    grid[i].push_back('.');
    for (int j = 1; j <= m; j++) {
      point[i].push_back(dummy);
      grid[i].push_back(str[j - 1]);
      point[i][j].now = pair<int, int>(i, j);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] != '.') {
        for (int k = i + 1; k <= n; k++) {
          if (grid[k][j] != '.') {
            point[i][j].down = pair<int, int>(k, j);
            point[k][j].up = pair<int, int>(i, j);
            break;
          }
        }
        for (int k = j + 1; k <= m; k++) {
          if (grid[i][k] != '.') {
            point[i][k].left = pair<int, int>(i, j);
            point[i][j].right = pair<int, int>(i, k);
            break;
          }
        }
      }
    }
  }
  int mx = -1;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] != '.') {
        int count = 1 + dfs(pair<int, int>(i, j));
        if (count > mx) {
          mx = max(mx, count);
          cnt = 0;
        }
        if (count == mx) {
          cnt++;
        }
        if (count == (n * m) && (n == 1 || m == 1)) {
          printf("%d 1\n", n * m);
          return 0;
        }
      }
    }
  }
  printf("%d %d\n", mx, cnt);
  return 0;
}
