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 N = 5000;
int n, m;
char s[N + 10][N + 10];
int L[N + 10], R[N + 10], U[N + 10], D[N + 10], l[N + 10], r[N + 10], u[N + 10],
    d[N + 10];
int rec[N + 10][N + 10], id[N + 10][2];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  memset(L, 0, sizeof(L));
  memset(R, 0, sizeof(R));
  memset(U, 0, sizeof(U));
  memset(D, 0, sizeof(D));
  memset(id, 0, sizeof(id));
  memset(rec, 0, sizeof(rec));
  int tot = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] != '.') {
        rec[i][j] = ++tot;
        id[tot][0] = i;
        id[tot][1] = j;
      }
  for (int i = 0; i < n; ++i) {
    int e;
    for (int j = 0, e = 0; j < m; ++j) {
      if (s[i][j] != '.') {
        if (e > 0)
          L[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
    for (int j = m - 1, e = 0; j >= 0; --j) {
      if (s[i][j] != '.') {
        if (e > 0)
          R[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
  }
  for (int j = 0; j < m; ++j) {
    int e;
    for (int i = 0, e = 0; i < n; ++i) {
      if (s[i][j] != '.') {
        if (e > 0)
          U[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
    for (int i = n - 1, e = 0; i >= 0; --i) {
      if (s[i][j] != '.') {
        if (e > 0)
          D[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
  }
  int best = 0;
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    for (int j = 1; j <= tot; ++j)
      l[j] = L[j], r[j] = R[j], u[j] = U[j], d[j] = D[j];
    int count = 0;
    int cur = i;
    int next;
    for (;;) {
      count++;
      if (s[id[cur][0]][id[cur][1]] == 'L') next = l[cur];
      if (s[id[cur][0]][id[cur][1]] == 'R') next = r[cur];
      if (s[id[cur][0]][id[cur][1]] == 'U') next = u[cur];
      if (s[id[cur][0]][id[cur][1]] == 'D') next = d[cur];
      if (l[cur] != 0) r[l[cur]] = r[cur];
      if (r[cur] != 0) l[r[cur]] = l[cur];
      if (u[cur] != 0) d[u[cur]] = d[cur];
      if (d[cur] != 0) u[d[cur]] = u[cur];
      if (next == 0) break;
      cur = next;
    }
    if (count > best) {
      best = count;
      cnt = 1;
    } else if (count == best) {
      cnt++;
    }
  }
  printf("%d %d\n", best, cnt);
  return 0;
}
