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;
string st = "UDLR.";
string a[5006];
char s[5006];
int p1[5006][4], p2[5006][4], b[5006];
int num[5006][5006];
int n, m, k, ans, ans1, nn;
int main() {
  nn = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    a[i] = s;
  }
  memset(p1, 0, sizeof(p1));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j - 1] != '.') num[i][j] = ++nn;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j - 1] != '.') {
        int mm = num[i][j];
        b[mm] = st.find(a[i][j - 1]);
        for (int k = i - 1; k > 0; --k)
          if (a[k][j - 1] != '.') {
            p1[mm][0] = num[k][j];
            break;
          }
        for (int k = i + 1; k <= n; ++k)
          if (a[k][j - 1] != '.') {
            p1[mm][1] = num[k][j];
            break;
          }
        for (int k = j - 1; k > 0; --k)
          if (a[i][k - 1] != '.') {
            p1[mm][2] = num[i][k];
            break;
          }
        for (int k = j + 1; k <= m; ++k)
          if (a[i][k - 1] != '.') {
            p1[mm][3] = num[i][k];
            break;
          }
      }
  ans = ans1 = 0;
  for (int i = 1; i <= nn; ++i) {
    memcpy(p2, p1, sizeof(p1));
    int j = i, tmp = 0;
    while (j) {
      p2[p2[j][0]][1] = p2[j][1];
      p2[p2[j][1]][0] = p2[j][0];
      p2[p2[j][2]][3] = p2[j][3];
      p2[p2[j][3]][2] = p2[j][2];
      ++tmp;
      j = p2[j][b[j]];
    }
    if (tmp > ans) {
      ans = tmp;
      ans1 = 1;
    } else if (tmp == ans)
      ans1++;
  }
  printf("%d %d\n", ans, ans1);
  return 0;
}
