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;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
int buff[5005];
int mem[5005];
int n, m;
int magic;
int L[5005], R[5005], U[5005], D[5005];
inline int valid(int i, int j) { return i >= 0 && j >= 0 && i < n && j < m; }
inline int id(int i, int j) {
  if (!valid(i, j)) return -1;
  return i * m + j;
}
inline int& at(int i, int j) { return buff[i * m + j]; }
char line[5005];
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int cvt[255];
void remove(int who) {
  int a = L[who];
  int b = R[who];
  int c = U[who];
  int d = D[who];
  if (a != -1) R[a] = b;
  if (b != -1) L[b] = a;
  if (c != -1) D[c] = d;
  if (d != -1) U[d] = c;
}
int main() {
  for (int i = 0; i < 4; ++i) cvt["UDLR"[i]] = i;
  cin >> n >> m;
  magic = n * m;
  for (int i = 0; i < n; ++i) {
    scanf("%s", line);
    for (int j = 0; j < m; ++j) at(i, j) = line[j];
  }
  int mans = 0, cans = 0;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j)
      if (at(i, j) != '.') {
        memcpy(mem, buff, sizeof buff);
        for (int a = 0; a < n; ++a)
          for (int b = 0; b < m; ++b) {
            L[id(a, b)] = id(a, b - 1);
            R[id(a, b)] = id(a, b + 1);
            U[id(a, b)] = id(a - 1, b);
            D[id(a, b)] = id(a + 1, b);
          }
        int tot = 0;
        int curr = id(i, j);
        for (; curr != -1;) {
          int d = cvt[buff[curr]];
          remove(curr);
          buff[curr] = '.';
          ++tot;
          if (d == 0) {
            int now = U[curr];
            while (now != -1) {
              if (buff[now] == '.') {
                remove(now);
                now = U[now];
              } else {
                break;
              }
            }
            curr = now;
          } else if (d == 1) {
            int now = D[curr];
            while (now != -1) {
              if (buff[now] == '.') {
                remove(now);
                now = D[now];
              } else {
                break;
              }
            }
            curr = now;
          } else if (d == 2) {
            int now = L[curr];
            while (now != -1) {
              if (buff[now] == '.') {
                remove(now);
                now = L[now];
              } else {
                break;
              }
            }
            curr = now;
          } else {
            int now = R[curr];
            while (now != -1) {
              if (buff[now] == '.') {
                remove(now);
                now = R[now];
              } else {
                break;
              }
            }
            curr = now;
          }
        }
        if (tot > mans) {
          mans = tot;
          cans = 1;
        } else if (tot == mans) {
          ++cans;
        }
        memcpy(buff, mem, sizeof buff);
      }
  cout << mans << " " << cans << endl;
  return 0;
}
