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;
int d[4];
int nx[5555][4], pr[5555][4];
int cn[5555][4], cp[5555][4];
int a[5555];
int n, m;
inline int go(int k, int l) {
  if (nx[k][l] != -2) return nx[k][l];
  if (k + d[l] >= n * m || k + d[l] < 0 ||
      (abs(d[l]) == 1 && (k + d[l]) / m != k / m))
    return nx[k][l] = -1;
  else if (a[k + d[l]] != -1)
    return nx[k][l] = k + d[l];
  else
    return nx[k][l] = go(k + d[l], l);
}
inline int gop(int k, int l) {
  if (pr[k][l] != -2) return pr[k][l];
  if (k - d[l] >= n * m || k - d[l] < 0 ||
      (abs(d[l]) == 1 && (k - d[l]) / m != k / m))
    return pr[k][l] = -1;
  else if (a[k - d[l]] != -1)
    return pr[k][l] = k - d[l];
  else
    return pr[k][l] = gop(k - d[l], l);
}
int main() {
  cin >> n >> m;
  d[0] = -m;
  d[1] = 1;
  d[2] = m;
  d[3] = -1;
  for (int(i) = 0; (i) < (n * m); ++(i)) {
    char ch;
    cin >> ch;
    if (ch == '.')
      a[i] = -1;
    else if (ch == 'U')
      a[i] = 0;
    else if (ch == 'R')
      a[i] = 1;
    else if (ch == 'D')
      a[i] = 2;
    else
      a[i] = 3;
    for (int(l) = 0; (l) < (4); ++(l)) nx[i][l] = pr[i][l] = -2;
  }
  for (int(i) = 0; (i) < (n * m); ++(i))
    for (int(l) = 0; (l) < (4); ++(l))
      if (nx[i][l] == -2) go(i, l);
  for (int(i) = 0; (i) < (n * m); ++(i))
    for (int(l) = 0; (l) < (4); ++(l))
      if (pr[i][l] == -2) gop(i, l);
  int ans = 0;
  int cnt = 0;
  for (int(i) = 0; (i) < (n * m); ++(i))
    if (a[i] != -1) {
      memcpy(cn, nx, sizeof(cn));
      memcpy(cp, pr, sizeof(cp));
      int j = i;
      int cur = 0;
      while (j != -1) {
        cur++;
        for (int(dir) = 0; (dir) < (4); ++(dir)) {
          int pp = cp[j][dir];
          int nn = cn[j][dir];
          if (~pp) cn[pp][dir] = nn;
          if (~nn) cp[nn][dir] = pp;
        }
        j = cn[j][a[j]];
      }
      if (cur > ans) {
        ans = cur;
        cnt = 1;
      } else if (cur == ans)
        cnt++;
    }
  cout << ans << " " << cnt << endl;
}
