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;
inline int count_bits(int x) {
  x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
  x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
  x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
  x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
  x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
  return x;
}
inline int count_bits_32(int x) {
  x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
  x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
  x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
  x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
  x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
  return x;
}
inline int count_bits_16(int x) {
  x = (x & 0x00005555) + ((x & 0x0000aaaa) >> 1);
  x = (x & 0x00003333) + ((x & 0x0000cccc) >> 2);
  x = (x & 0x00000f0f) + ((x & 0x0000f0f0) >> 4);
  x = (x & 0x000000ff) + ((x & 0x0000ff00) >> 8);
  return x;
}
inline int count_bits_8(int x) {
  x = (x & 0x00000055) + ((x & 0x000000aa) >> 1);
  x = (x & 0x00000033) + ((x & 0x000000cc) >> 2);
  x = (x & 0x0000000f) + ((x & 0x0000f0f0) >> 4);
  return x;
}
int reverse_bits(int x) {
  x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
  x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
  x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
  x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
  x = ((x >> 16) & 0x0000ffff) | ((x << 16) & 0xffff0000);
  return x;
}
template <class T>
inline T low_bit(T x) {
  return x & -x;
}
template <class T>
inline T high_bit(T x) {
  T p = low_bit(x);
  while (p != x) x -= p, p = low_bit(x);
  return p;
}
template <class T>
inline void RD(T &x) {
  cin >> x;
}
template <class T>
inline void RD(T &x0, T &x1) {
  RD(x0), RD(x1);
}
template <class T>
inline void RD(T &x0, T &x1, T &x2) {
  RD(x0), RD(x1), RD(x2);
}
template <class T>
inline void RD(T &x0, T &x1, T &x2, T &x3) {
  RD(x0), RD(x1), RD(x2), RD(x3);
}
template <class T>
inline void RD(T &x0, T &x1, T &x2, T &x3, T &x4) {
  RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);
}
template <class T>
inline void RD(T &x0, T &x1, T &x2, T &x3, T &x4, T &x5) {
  RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);
}
template <class T>
inline void RST(T &A) {
  memset(A, 0, sizeof(A));
}
template <class T>
inline void RST(T &A0, T &A1) {
  RST(A0), RST(A1);
}
template <class T>
inline void RST(T &A0, T &A1, T &A2) {
  RST(A0), RST(A1), RST(A2);
}
template <class T>
inline void RST(T &A0, T &A1, T &A2, T &A3) {
  RST(A0), RST(A1), RST(A2), RST(A3);
}
template <class T>
inline void RST(T &A0, T &A1, T &A2, T &A3, T &A4) {
  RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);
}
template <class T>
inline void RST(T &A0, T &A1, T &A2, T &A3, T &A4, T &A5) {
  RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);
}
template <class T>
inline void FLC(T &A, int x) {
  memset(A, x, sizeof(A));
}
template <class T>
inline void FLC(T &A0, T &A1, int x) {
  FLC(A0, x), FLC(A1, x);
}
template <class T>
inline void FLC(T &A0, T &A1, T &A2, int x) {
  FLC(A0, x), FLC(A1, x), FLC(A2, x);
}
template <class T>
inline void FLC(T &A0, T &A1, T &A2, T &A3, int x) {
  FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);
}
template <class T>
inline void FLC(T &A0, T &A1, T &A2, T &A3, T &A4, int x) {
  FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);
}
template <class T>
inline void FLC(T &A0, T &A1, T &A2, T &A3, T &A4, T &A5, int x) {
  FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);
}
template <class T>
inline void checkMin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkMax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T sqr(T a) {
  return a * a;
}
template <class T>
inline T cub(T a) {
  return a * a * a;
}
template <class T>
inline double dist(T x0, T x1, T y0, T y1) {
  return sqrt(sqr(x0 - x1) + sqr(y0 - y1));
}
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <class T>
inline T random(T l, T r) {
  return rand() % (r - l + 1) + l;
}
const int MOD = 1000000007;
const int INF = 0x7fffffff;
const int MaxN = 5009;
const int MaxK = 5009;
int N, M, tot;
char A[MaxN][MaxN], B[MaxK];
int L[MaxK], R[MaxK], U[MaxK], D[MaxK];
int id[MaxN][MaxN];
void Init() {
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++) {
      L[id[i][j]] = id[i][j - 1];
      R[id[i][j]] = id[i][j + 1];
      U[id[i][j]] = id[i - 1][j];
      D[id[i][j]] = id[i + 1][j];
    }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      if (A[i][j] == '.') {
        R[L[id[i][j]]] = R[id[i][j]];
        L[R[id[i][j]]] = L[id[i][j]];
        U[D[id[i][j]]] = U[id[i][j]];
        D[U[id[i][j]]] = D[id[i][j]];
      }
}
void Union(int now) {
  R[L[now]] = R[now];
  L[R[now]] = L[now];
  U[D[now]] = U[now];
  D[U[now]] = D[now];
}
int Find(int now) {
  if (now == 0) return 0;
  Union(now);
  if (B[now] == 'U') return Find(U[now]) + 1;
  if (B[now] == 'D') return Find(D[now]) + 1;
  if (B[now] == 'L') return Find(L[now]) + 1;
  if (B[now] == 'R') return Find(R[now]) + 1;
}
void Solve() {
  int BestAns = 0, AnsNum = 0;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      if (A[i][j] != '.') {
        Init();
        int ret = Find(id[i][j]);
        if (ret > BestAns) {
          BestAns = ret;
          AnsNum = 1;
        } else if (ret == BestAns)
          AnsNum++;
      }
  cout << BestAns << " " << AnsNum << "\n";
}
int main() {
  cin >> N >> M;
  tot = 0;
  memset(id, 0, sizeof(id));
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++) {
      cin >> A[i][j];
      id[i][j] = ++tot;
      B[tot] = A[i][j];
    }
  Solve();
  return 0;
}
