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 MAX = 5001;
struct node {
  pair<int, int> l, r, u, d;
  node() {}
  void assign(int id, pair<int, int> hh) {
    if (id == 0) l = hh;
    if (id == 1) r = hh;
    if (id == 2) u = hh;
    if (id == 3) d = hh;
  }
};
vector<vector<node> > bb;
vector<vector<node> > xi;
char mm[MAX][MAX];
vector<vector<int> > ans;
int n, m;
int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
inline bool core(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int main() {
  scanf("%d%d", &n, &m);
  bb.resize(n), xi.resize(n), ans.resize(n);
  for (int i = 0; i < n; i++)
    bb[i].resize(m), xi[i].resize(m), ans[i].resize(m);
  for (int i = 0; i < n; i++) scanf("%s", mm[i]);
  for (int r = 0; r < n; r++) {
    for (int c = 0; c < m; c++) {
      if (mm[r][c] == '.') continue;
      for (int d = 0; d < 4; d++) {
        for (int k = 1; k <= max(n, m); k++) {
          int x1 = r + k * dx[d], y1 = c + k * dy[d];
          if (!core(x1, y1)) {
            xi[r][c].assign(d, {-1, -1});
            break;
          } else {
            if (mm[x1][y1] != '.') {
              xi[r][c].assign(d, {x1, y1});
              break;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == '.') continue;
      for (int r = 0; r < n; r++) {
        for (int c = 0; c < m; c++) bb[r][c] = xi[r][c];
      }
      int cnt = 0;
      int rs = i, cs = j;
      while (rs != -1) {
        cnt++;
        pair<int, int> l = bb[rs][cs].l, r = bb[rs][cs].r, u = bb[rs][cs].u,
                       d = bb[rs][cs].d;
        if (l.first != -1) {
          bb[l.first][l.second].r = r;
        }
        if (r.first != -1) {
          bb[r.first][r.second].l = l;
        }
        if (u.first != -1) {
          bb[u.first][u.second].d = d;
        }
        if (d.first != -1) {
          bb[d.first][d.second].u = u;
        }
        if (mm[rs][cs] == 'L') {
          pair<int, int> l = bb[rs][cs].l;
          rs = l.first, cs = l.second;
        } else if (mm[rs][cs] == 'R') {
          pair<int, int> l = bb[rs][cs].r;
          rs = l.first, cs = l.second;
        } else if (mm[rs][cs] == 'D') {
          pair<int, int> l = bb[rs][cs].d;
          rs = l.first, cs = l.second;
        } else if (mm[rs][cs] == 'U') {
          pair<int, int> l = bb[rs][cs].u;
          rs = l.first, cs = l.second;
        }
      }
      ans[i][j] = cnt;
    }
  }
  int mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == '.') continue;
      mx = max(mx, ans[i][j]);
    }
  }
  int cc = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == '.') continue;
      if (ans[i][j] == mx) cc++;
    }
  }
  printf("%d %d\n", mx, cc);
  return 0;
}
