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>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
int n, m;
string A[5000], AA[5000];
pair<int, int> e;
map<pair<int, int>, pair<int, int> > L, R, U, D, LL, RR, UU, DD;
pair<int, int> FindL(pair<int, int> x) {
  if (x == e) return e;
  if (A[x.first][x.second] != '.') return x;
  return L[x] = FindL(L[x]);
}
pair<int, int> FindR(pair<int, int> x) {
  if (x == e) return e;
  if (A[x.first][x.second] != '.') return x;
  return R[x] = FindR(R[x]);
}
pair<int, int> FindU(pair<int, int> x) {
  if (x == e) return e;
  if (A[x.first][x.second] != '.') return x;
  return U[x] = FindU(U[x]);
}
pair<int, int> FindD(pair<int, int> x) {
  if (x == e) return e;
  if (A[x.first][x.second] != '.') return x;
  return D[x] = FindD(D[x]);
}
int main() {
  cin >> n >> m;
  for (int(i) = (0); (i) < (n); ++(i)) cin >> A[i];
  e = make_pair(-1, -1);
  for (int(i) = (0); (i) < (n); ++(i))
    for (int(j) = (0); (j) < (m); ++(j)) {
      pair<int, int> t = make_pair(i, j);
      L[t] = e;
      R[t] = e;
      U[t] = e;
      D[t] = e;
    }
  for (int(i) = (0); (i) < (n); ++(i)) {
    pair<int, int> last = e;
    for (int(j) = (0); (j) < (m); ++(j)) {
      L[make_pair(i, j)] = last;
      if (A[i][j] != '.') last = make_pair(i, j);
    }
  }
  for (int(i) = (0); (i) < (n); ++(i)) {
    pair<int, int> last = e;
    for (int(j) = (m)-1; (j) >= (0); --(j)) {
      R[make_pair(i, j)] = last;
      if (A[i][j] != '.') last = make_pair(i, j);
    }
  }
  for (int(i) = (0); (i) < (m); ++(i)) {
    pair<int, int> last = e;
    for (int(j) = (0); (j) < (n); ++(j)) {
      U[make_pair(j, i)] = last;
      if (A[j][i] != '.') last = make_pair(j, i);
    }
  }
  for (int(i) = (0); (i) < (m); ++(i)) {
    pair<int, int> last = e;
    for (int(j) = (n)-1; (j) >= (0); --(j)) {
      D[make_pair(j, i)] = last;
      if (A[j][i] != '.') last = make_pair(j, i);
    }
  }
  LL = L, RR = R, DD = D, UU = U;
  for (int(i) = (0); (i) < (n); ++(i)) AA[i] = A[i];
  int res = 0, num = 0;
  for (int(i) = (0); (i) < (n); ++(i))
    for (int(j) = (0); (j) < (m); ++(j))
      if (A[i][j] != '.') {
        for (int(k) = (0); (k) < (n); ++(k)) A[k] = AA[k];
        L = LL, R = RR, U = UU, D = DD;
        int count = 0;
        int x = i, y = j;
        pair<int, int> t;
        while (true) {
          count++;
          if (A[x][y] == 'L') {
            if (y == 0) break;
            t = FindL(make_pair(x, y - 1));
            if (t == e) break;
            A[x][y] = '.';
            x = t.first;
            y = t.second;
          } else if (A[x][y] == 'R') {
            if (y == m - 1) break;
            t = FindR(make_pair(x, y + 1));
            if (t == e) break;
            A[x][y] = '.';
            x = t.first;
            y = t.second;
          } else if (A[x][y] == 'U') {
            if (x == 0) break;
            t = FindU(make_pair(x - 1, y));
            if (t == e) break;
            A[x][y] = '.';
            x = t.first;
            y = t.second;
          } else if (A[x][y] == 'D') {
            if (x == n - 1) break;
            t = FindD(make_pair(x + 1, y));
            if (t == e) break;
            A[x][y] = '.';
            x = t.first;
            y = t.second;
          }
        }
        if (count > res) {
          res = count;
          num = 1;
        } else if (count == res)
          num++;
      }
  printf("%d %d\n", res, num);
}
