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 MX = 5010;
int bit[80][MX], bit2[MX][80], b1[80][MX], b2[MX][80];
int sum(int *a, int i) {
  int ret = 0;
  for (; i; i -= i & -i) ret += a[i];
  return ret;
}
void add(int *a, int i, int x, int sz) {
  for (; i <= sz; i += i & -i) a[i] += x;
}
int h, w;
char in[MX][MX], in2[MX][MX];
void run() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> in2[i];
  if (h > w) {
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) in[w - j - 1][i] = in2[i][j];
    for (int i = 0; i < w; i++)
      for (int j = 0; j < h; j++) {
        if (in[i][j] == 'R')
          in[i][j] = 'U';
        else if (in[i][j] == 'L')
          in[i][j] = 'D';
        else if (in[i][j] == 'U')
          in[i][j] = 'L';
        else if (in[i][j] == 'D')
          in[i][j] = 'R';
      }
    swap(h, w);
  } else
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) in[i][j] = in2[i][j];
  for (int i = 0; i < h + 1; i++)
    for (int j = 0; j < w + 1; j++) bit[i][j] = bit2[j][i] = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (in[i][j] != '.')
        add(bit[i], j + 1, 1, MX), add(bit2[j], i + 1, 1, 80);
  int ans = 0, mx = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (in[i][j] != '.') {
        for (int y = 0; y < h + 1; y++)
          for (int x = 0; x < w + 1; x++)
            b1[y][x] = bit[y][x], b2[y][x] = bit2[y][x];
        int y = i, x = j, cnt = 0;
        for (;;) {
          cnt++;
          add(b1[y], x + 1, -1, MX);
          add(b2[x], y + 1, -1, 80);
          int l, r, mid;
          if (in[y][x] == 'U') {
            l = -1;
            r = y;
            while (l + 1 < r) {
              mid = (l + r) / 2;
              if (sum(b2[x], y) - sum(b2[x], mid) < 1)
                r = mid;
              else
                l = mid;
            }
            if (l == -1) break;
            y = l;
          } else if (in[y][x] == 'D') {
            l = y;
            r = h;
            while (l + 1 < r) {
              mid = (l + r) / 2;
              if (sum(b2[x], mid + 1) - sum(b2[x], y + 1) < 1)
                l = mid;
              else
                r = mid;
            }
            if (r == h) break;
            y = r;
          } else if (in[y][x] == 'L') {
            l = -1;
            r = x;
            while (l + 1 < r) {
              mid = (l + r) / 2;
              if (sum(b1[y], x) - sum(b1[y], mid) < 1)
                r = mid;
              else
                l = mid;
            }
            if (l == -1) break;
            x = l;
          } else if (in[y][x] == 'R') {
            l = x;
            r = w;
            while (l + 1 < r) {
              mid = (l + r) / 2;
              if (sum(b1[y], mid + 1) - sum(b1[y], x + 1) < 1)
                l = mid;
              else
                r = mid;
            }
            if (r == w) break;
            x = r;
          } else
            assert(0);
        }
        if (cnt > mx) ans = 0, mx = cnt;
        if (mx == cnt) ans++;
      }
  cout << mx << " " << ans << endl;
}
int main() { run(); }
