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>
int a[10001], up[10001], down[10001], left[10001], right[10001], n, m, now, ans,
    total;
bool b[10001];
void readin() {
  int i, j, last[10001], pre, num;
  char tmp, ch;
  scanf("%d %d", &n, &m);
  scanf("%c", &tmp);
  num = n * m;
  for (i = 1; i <= m; ++i) last[10001] = -1;
  for (i = 1; i <= num; ++i) up[i] = down[i] = left[i] = right[i] = -1;
  for (i = 1; i <= n; ++i) {
    pre = -1;
    for (j = 1; j <= m; ++j) {
      b[(i - 1) * m + j] = false;
      scanf("%c", &ch);
      switch (ch) {
        case '.':
          a[(i - 1) * m + j] = 0;
          break;
        case 'U':
          a[(i - 1) * m + j] = 1;
          break;
        case 'D':
          a[(i - 1) * m + j] = 2;
          break;
        case 'L':
          a[(i - 1) * m + j] = 3;
          break;
        case 'R':
          a[(i - 1) * m + j] = 4;
          break;
      }
      if (ch == '.') continue;
      if (last[j] > 0) {
        up[(i - 1) * m + j] = last[j];
        down[last[j]] = (i - 1) * m + j;
      }
      last[j] = (i - 1) * m + j;
      if (pre > 0) {
        left[(i - 1) * m + j] = pre;
        right[pre] = (i - 1) * m + j;
      }
      pre = (i - 1) * m + j;
    }
    scanf("%c", &tmp);
  }
}
void del(int t) {
  if (up[t] > 0) down[up[t]] = down[t];
  if (down[t] > 0) up[down[t]] = up[t];
  if (left[t] > 0) right[left[t]] = right[t];
  if (right[t] > 0) left[right[t]] = left[t];
}
void back(int t) {
  if (up[t] > 0) down[up[t]] = t;
  if (down[t] > 0) up[down[t]] = t;
  if (left[t] > 0) right[left[t]] = t;
  if (right[t] > 0) left[right[t]] = t;
}
void search(int t) {
  int i, x, y;
  if (t < 0 || t > n * m) return;
  y = t % m;
  if (y == 0) {
    x = t / m;
    y = m;
  } else
    x = t / m + 1;
  b[t] = true;
  ++now;
  if (now == ans) ++total;
  if (now > ans) {
    ans = now;
    total = 1;
  }
  switch (a[t]) {
    case 1:
      del(t);
      search(up[t]);
      back(t);
      break;
    case 2:
      del(t);
      search(down[t]);
      back(t);
      break;
    case 3:
      del(t);
      search(left[t]);
      back(t);
      break;
    case 4:
      del(t);
      search(right[t]);
      back(t);
      break;
  }
  --now;
  b[t] = false;
}
void solve() {
  int i, j;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      if (a[(i - 1) * m + j] > 0) {
        now = 0;
        search((i - 1) * m + j);
        if (now > ans) {
          ans = now;
          total = 1;
          continue;
        }
        if (now == ans) ++total;
      }
}
void print() { printf("%d %d\n", ans, total); }
int main() {
  readin();
  solve();
  print();
  return 0;
}
