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 maxN = 5000 + 5;
const string M = "URDL";
const int opos[] = {2, 3, 0, 1};
int n, m, cnt;
vector<char> mat[maxN];
struct node {
  pair<int, int> a[4];
  node() { a[0] = a[1] = a[2] = a[3] = pair<int, int>(-1, -1); }
};
vector<node> mov[maxN], asl[maxN];
inline void init() {
  for (int i = 1; i <= n; i++) {
    int past = -1;
    for (int j = 1; j <= m; j++)
      if (mat[i][j] != '.') {
        if (past != -1) {
          asl[i][past].a[1] = pair<int, int>(i, j);
          asl[i][j].a[3] = pair<int, int>(i, past);
        }
        past = j;
      }
  }
  for (int j = 1; j <= m; j++) {
    int past = -1;
    for (int i = 1; i <= n; i++)
      if (mat[i][j] != '.') {
        if (past != -1) {
          asl[past][j].a[2] = pair<int, int>(i, j);
          asl[i][j].a[0] = pair<int, int>(past, j);
        }
        past = i;
      }
  }
}
inline void SET() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (mat[i][j] != '.') mov[i][j] = asl[i][j];
}
inline void go(int x, int y) {
  if (x == -1) return;
  cnt++;
  pair<int, int> tmp;
  for (int i = 0; i < 4; i++)
    if ((tmp = mov[x][y].a[i]) != pair<int, int>(-1, -1)) {
      mov[tmp.first][tmp.second].a[opos[i]] = mov[x][y].a[opos[i]];
    }
  int ind = M.find(mat[x][y]);
  go(mov[x][y].a[ind].first, mov[x][y].a[ind].second);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    mov[i].resize(m + 1);
    mat[i].resize(m + 1);
    asl[i].resize(m + 1);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mat[i][j];
  int maxi = -1, cmaxi = -1;
  init();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (mat[i][j] != '.') {
        SET();
        cnt = 0;
        go(i, j);
        (maxi == cnt) ? cmaxi++ : (maxi < cnt) ? maxi = cnt, cmaxi = 1 : true;
      }
  cout << maxi << ' ' << cmaxi << endl;
  return 0;
}
