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 = 5010;
const int maxk = 100000;
int n, m;
vector<vector<int> > table;
set<int> S[2][maxn];
map<char, int> M;
char c;
int best, bestcnt;
bool bs(int first, int second, int dir, int &nx, int &ny) {
  set<int>::iterator it;
  nx = first;
  ny = second;
  if (dir == 0) {
    it = S[1][second].lower_bound(first);
    if (S[1][second].size()) it--;
    if (it != S[1][second].end() && *it < first) nx = *it;
  }
  if (dir == 1) {
    it = S[0][first].lower_bound(second + 1);
    if (it != S[0][first].end() && *it > second) ny = *it;
  }
  if (dir == 2) {
    it = S[1][second].lower_bound(first + 1);
    if (it != S[1][second].end() && *it > first) nx = *it;
  }
  if (dir == 3) {
    it = S[0][first].lower_bound(second);
    if (S[0][first].size()) it--;
    if (it != S[0][first].end() && *it < second) ny = *it;
  }
  if (first != nx || second != ny) return 1;
  return 0;
}
void dfs(int first, int second, int d) {
  if (table[first][second] == 4) return;
  if (d >= best) {
    if (d > best) {
      best = d;
      bestcnt = 0;
    }
    bestcnt++;
  }
  int nx, ny;
  int dir = table[first][second];
  table[first][second] = 4;
  S[0][first].erase(second);
  S[1][second].erase(first);
  if (bs(first, second, dir, nx, ny)) {
    dfs(nx, ny, d + 1);
  }
  table[first][second] = dir;
  S[0][first].insert(second);
  S[1][second].insert(first);
}
int main() {
  scanf("%d%d\n", &n, &m);
  M['U'] = 0;
  M['R'] = 1;
  M['D'] = 2;
  M['L'] = 3;
  M['.'] = 4;
  table.resize(n + 1);
  for (int i = 0, _n = (n); i < _n; i++) {
    for (int j = 0, _n = (m); j < _n; j++) {
      scanf("%c", &c);
      table[i].push_back(M[c]);
      if (c != '.') {
        S[0][i].insert(j);
        S[1][j].insert(i);
      }
    }
    scanf("\n");
  }
  for (int i = 0, _n = (n); i < _n; i++) {
    for (int j = 0, _n = (n); j < _n; j++) {
      dfs(i, j, 1);
    }
  }
  printf("%d %d\n", best, bestcnt);
  return 0;
}
