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;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T>
T gcd(T a, T b) {
  for (T c; b; c = a, a = b, b = c % b)
    ;
  return a;
}
template <class T>
void out(const vector<T> &a) {
  for (int i = 0; i < ((int)(a).size()); ++i) cout << a[i] << " ";
  cout << endl;
}
int countbit(int n) { return n == 0 ? 0 : 1 + countbit(n & (n - 1)); }
const int d8[8][2] = {{1, 0}, {-1, 0},  {0, 1},  {0, -1},
                      {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};
const int d4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
inline int dcmp(double x) { return (x > EPS) - (x < -EPS); }
inline double cross(const complex<double> &a, const complex<double> &b) {
  return (conj(a) * b).imag();
}
inline double dot(const complex<double> &a, const complex<double> &b) {
  return (conj(a) * b).real();
}
const int N = 5000;
char s[N][N + 10];
int idx[N][N];
pair<int, int> A[N];
int L[N], R[N], U[N], D[N];
int _L[N], _R[N], _U[N], _D[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '.') continue;
      idx[i][j] = cnt;
      A[cnt++] = make_pair(i, j);
    }
  for (int v = 0; v < cnt; ++v) {
    int i = A[v].first;
    int j = A[v].second;
    int u = idx[i][j];
    L[u] = -1;
    for (int k = j - 1; k >= 0; --k)
      if (s[i][k] != '.') {
        L[u] = idx[i][k];
        break;
      }
    R[u] = -1;
    for (int k = j + 1; k < m; ++k)
      if (s[i][k] != '.') {
        R[u] = idx[i][k];
        break;
      }
    U[u] = -1;
    for (int k = i - 1; k >= 0; --k)
      if (s[k][j] != '.') {
        U[u] = idx[k][j];
        break;
      }
    D[u] = -1;
    for (int k = i + 1; k < n; ++k)
      if (s[k][j] != '.') {
        D[u] = idx[k][j];
        break;
      }
  }
  copy(L, L + cnt, _L);
  copy(R, R + cnt, _R);
  copy(U, U + cnt, _U);
  copy(D, D + cnt, _D);
  int best = 0, best_cnt = 0;
  for (int v = 0; v < cnt; ++v) {
    int i = A[v].first;
    int j = A[v].second;
    copy(_L, _L + cnt, L);
    copy(_R, _R + cnt, R);
    copy(_U, _U + cnt, U);
    copy(_D, _D + cnt, D);
    int sum = 0;
    while (true) {
      int u;
      if (s[i][j] == 'D')
        u = D[idx[i][j]];
      else if (s[i][j] == 'U')
        u = U[idx[i][j]];
      else if (s[i][j] == 'L')
        u = L[idx[i][j]];
      else
        u = R[idx[i][j]];
      ++sum;
      if (D[idx[i][j]] >= 0) U[D[idx[i][j]]] = U[idx[i][j]];
      if (U[idx[i][j]] >= 0) D[U[idx[i][j]]] = D[idx[i][j]];
      if (L[idx[i][j]] >= 0) R[L[idx[i][j]]] = R[idx[i][j]];
      if (R[idx[i][j]] >= 0) L[R[idx[i][j]]] = L[idx[i][j]];
      if (u < 0) break;
      i = A[u].first;
      j = A[u].second;
    }
    if (best < sum) {
      best = sum;
      best_cnt = 1;
    } else if (best == sum)
      best_cnt++;
  }
  printf("%d %d\n", best, best_cnt);
  return 0;
}
