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;
char s[maxn];
int n, m;
struct Node {
  int l, r, u, d;
  void init() { l = r = u = d = -1; }
} node[maxn];
void build() {
  int i, j, k;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      int cur = i * m + j;
      node[cur].init();
      if (s[cur] == '.') continue;
      for (k = i + 1; k < n; k++)
        if (s[k * m + j] != '.') break;
      if (k < n) node[cur].d = k * m + j;
      for (k = i - 1; k >= 0; k--)
        if (s[k * m + j] != '.') break;
      if (k >= 0) node[cur].u = k * m + j;
      for (k = j - 1; k >= 0; k--)
        if (s[i * m + k] != '.') break;
      if (k >= 0) node[cur].l = i * m + k;
      for (k = j + 1; k < m; k++)
        if (s[i * m + k] != '.') break;
      if (k < m) node[cur].r = i * m + k;
    }
}
void lr(int cur) {
  int l = node[cur].l, r = node[cur].r;
  if (l == -1) {
    if (r == -1) return;
    node[r].l = -1;
  } else {
    if (r == -1)
      node[l].r = -1;
    else {
      node[l].r = r;
      node[r].l = l;
    }
  }
}
void ud(int cur) {
  int u = node[cur].u, d = node[cur].d;
  if (u == -1) {
    if (d == -1) return;
    node[d].u = u;
  } else {
    if (d == -1)
      node[u].d = -1;
    else {
      node[d].u = u;
      node[u].d = d;
    }
  }
}
int solve(int x, int y) {
  build();
  int cur = x * m + y;
  int ans = 0;
  while (cur != -1) {
    ans++;
    int tp = cur;
    switch (s[cur]) {
      case 'D':
        cur = node[cur].d;
        break;
      case 'U':
        cur = node[cur].u;
        break;
      case 'L':
        cur = node[cur].l;
        break;
      case 'R':
        cur = node[cur].r;
        break;
    }
    lr(tp);
    ud(tp);
  }
  return ans;
}
int main() {
  while (scanf("%d%d", &n, &m) == 2) {
    int i, j;
    for (i = 0; i < n; i++) scanf("%s", s + i * m);
    int ans = 0, num = 1, tmp;
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) {
        if (s[i * m + j] == '.') continue;
        tmp = solve(i, j);
        if (tmp > ans)
          ans = tmp, num = 1;
        else if (tmp == ans)
          num++;
      }
    printf("%d %d\n", ans, num);
  }
  return 0;
}
