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;
template <class T>
inline bool gmin(T &a, T b) {
  if (a > b) return a = b, true;
  return false;
}
template <class T>
inline bool gmax(T &a, T b) {
  if (a < b) return a = b, true;
  return false;
}
template <class T>
T exgcd(T a, T b, T &first, T &second) {
  if (!b)
    return first = (T)1, second = (T)0, a;
  else {
    T d = exgcd(b, a % b, second, first);
    return second -= a / b * first, d;
  }
}
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = 1e10;
const double EPS = 1e-9;
const double PI = 3.14159265358979323846264338327950288;
const double TAU = 2.0 * PI;
inline int sgn(const double &a) { return a > EPS ? 1 : (a < -EPS ? -1 : 0); }
inline int lowbit(int i) { return i & (-i); }
struct Initializer {
  Initializer() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
} initializer;
const int MAXN = 5005;
int n, m;
int tol[MAXN], tor[MAXN], tou[MAXN], tod[MAXN];
int l[MAXN], r[MAXN], d[MAXN], u[MAXN];
char t[MAXN][MAXN];
inline int idx(int i, int j) { return (i - 1) * n + j; }
void update(int i, int j) {
  if (r[idx(i, j)]) l[idx(i, r[idx(i, j)])] = l[idx(i, j)];
  if (l[idx(i, j)]) r[idx(i, l[idx(i, j)])] = r[idx(i, j)];
  if (u[idx(i, j)]) d[idx(u[idx(i, j)], j)] = d[idx(i, j)];
  if (d[idx(i, j)]) u[idx(d[idx(i, j)], j)] = u[idx(i, j)];
}
int main() {
  scanf("%d %d", &m, &n);
  for (int i = 1; i <= m; i++) scanf("%s", t[i] + 1);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      for (int k = j - 1; k >= 1; k--)
        if (t[i][k] != '.') {
          tol[idx(i, j)] = k;
          break;
        }
      for (int k = i - 1; k >= 1; k--)
        if (t[k][j] != '.') {
          tou[idx(i, j)] = k;
          break;
        }
      for (int k = j + 1; k <= n; k++)
        if (t[i][k] != '.') {
          tor[idx(i, j)] = k;
          break;
        }
      for (int k = i + 1; k <= m; k++)
        if (t[k][j] != '.') {
          tod[idx(i, j)] = k;
          break;
        }
    }
  int ans = 0, cnt = 0;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (t[i][j] != '.') {
        for (int p = 1; p <= m; p++)
          for (int q = 1; q <= n; q++) {
            l[idx(p, q)] = tol[idx(p, q)];
            r[idx(p, q)] = tor[idx(p, q)];
            u[idx(p, q)] = tou[idx(p, q)];
            d[idx(p, q)] = tod[idx(p, q)];
          }
        int rec = 0;
        for (int first = i, second = j; first && second;) {
          rec++;
          update(first, second);
          switch (t[first][second]) {
            case 'L':
              second = l[idx(first, second)];
              break;
            case 'R':
              second = r[idx(first, second)];
              break;
            case 'U':
              first = u[idx(first, second)];
              break;
            case 'D':
              first = d[idx(first, second)];
              break;
          }
        }
        if (rec > ans)
          ans = rec, cnt = 1;
        else {
          if (rec == ans) cnt++;
        }
      }
  printf("%d %d\n", ans, cnt);
  return 0;
}
