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;
struct Node {
  short left, right, down, up;
  Node(short l = -1, short r = -1, short u = -1, short d = -1)
      : left(l), right(r), down(d), up(u) {}
};
char field[5000][5000];
int main() {
  short n, m;
  cin >> n >> m;
  vector<vector<Node> > table(n, vector<Node>(m));
  vector<vector<Node> > grid(n, vector<Node>(m));
  for (int _n(n), i(0); i < _n; i++)
    for (int _n(m), j(0); j < _n; j++) cin >> field[i][j];
  for (int _n(n), i(0); i < _n; i++)
    for (int _n(m), j(0); j < _n; j++) {
      if (field[i][j] == '.') continue;
      short left = -1;
      for (short k = j - 1; k >= 0; --k)
        if (field[i][k] != '.') {
          left = k;
          break;
        }
      short right = -1;
      for (short k = j + 1; k < m; ++k)
        if (field[i][k] != '.') {
          right = k;
          break;
        }
      short up = -1;
      for (short k = i - 1; k >= 0; --k)
        if (field[k][j] != '.') {
          up = k;
          break;
        }
      short down = -1;
      for (short k = i + 1; k < n; ++k)
        if (field[k][j] != '.') {
          down = k;
          break;
        }
      grid[i][j] = Node(left, right, up, down);
    }
  int ans = 0, cnt = 0;
  for (int _n(n), i(0); i < _n; i++)
    for (int _n(m), j(0); j < _n; j++)
      if (field[i][j] != '.') {
        for (int _n(n), k(0); k < _n; k++)
          memcpy(&table[k][0], &grid[k][0], sizeof(Node) * m);
        int score = 0;
        short row = i, col = j;
        while (row != -1 && col != -1) {
          ++score;
          const Node &node = table[row][col];
          if (node.left != -1) table[row][node.left].right = node.right;
          if (node.right != -1) table[row][node.right].left = node.left;
          if (node.up != -1) table[node.up][col].down = node.down;
          if (node.down != -1) table[node.down][col].up = node.up;
          switch (field[row][col]) {
            case 'L': {
              col = node.left;
              break;
            }
            case 'R': {
              col = node.right;
              break;
            }
            case 'D': {
              row = node.down;
              break;
            }
            default: {
              row = node.up;
              break;
            }
          }
        }
        if (score > ans) {
          ans = score;
          cnt = 1;
        } else if (score == ans)
          cnt++;
      }
  cout << ans << ' ' << cnt << endl;
  return 0;
}
