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 g[MAXN][MAXN];
int l[MAXN], r[MAXN], u[MAXN], d[MAXN];
int n, m;
int id(int x, int y) { return (x - 1) * m + y; }
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", g[i] + 1);
  }
  int res = -1, ans;
  for (int X = 1; X <= n; X++)
    for (int Y = 1; Y <= m; Y++) {
      if (g[X][Y] == '.') continue;
      for (int i = 1; i <= n; i++)
        for (int j = 1, pre = 0; j <= m; j++) {
          if (g[i][j] == '.') continue;
          int v = id(i, j);
          l[v] = pre;
          if (pre) r[pre] = v;
          r[v] = 0;
          pre = v;
        }
      for (int j = 1; j <= m; j++)
        for (int i = 1, pre = 0; i <= n; i++) {
          if (g[i][j] == '.') continue;
          int v = id(i, j);
          u[v] = pre;
          if (pre) d[pre] = v;
          d[v] = 0;
          pre = v;
        }
      int x = X, y = Y, step = 0;
      while (1) {
        int now = id(x, y);
        r[l[now]] = r[now];
        l[r[now]] = l[now];
        u[d[now]] = u[now];
        d[u[now]] = d[now];
        if (g[x][y] == 'D') now = d[now];
        if (g[x][y] == 'R') now = r[now];
        if (g[x][y] == 'U') now = u[now];
        if (g[x][y] == 'L') now = l[now];
        step++;
        if (!now) break;
        x = (now - 1) / m + 1;
        y = (now - 1) % m + 1;
      }
      if (step > res)
        res = step, ans = 1;
      else if (step == res)
        ans++;
    }
  printf("%d %d\n", res, ans);
  return 0;
}
