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 int N = 5005;
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  char a[n + 1][m + 1];
  pair<int, int> L[n + 1][m + 1], R[n + 1][m + 1], U[n + 1][m + 1],
      D[n + 1][m + 1], LL[n + 1][m + 1], RR[n + 1][m + 1], UU[n + 1][m + 1],
      DD[n + 1][m + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    pair<int, int> cur = make_pair(-1, -1);
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '.') {
        L[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
    cur = make_pair(-1, -1);
    for (int j = m; j >= 1; j--) {
      if (a[i][j] != '.') {
        R[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    pair<int, int> cur = make_pair(-1, -1);
    for (int i = 1; i <= n; i++) {
      if (a[i][j] != '.') {
        U[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
    cur = make_pair(-1, -1);
    for (int i = n; i >= 1; i--) {
      if (a[i][j] != '.') {
        D[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      UU[i][j] = U[i][j];
      DD[i][j] = D[i][j];
      LL[i][j] = L[i][j];
      RR[i][j] = R[i][j];
    }
  }
  int mx = 0, cur = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '.') {
        for (int ii = 1; ii <= n; ii++) {
          for (int jj = 1; jj <= m; jj++) {
            L[ii][jj] = LL[ii][jj];
            R[ii][jj] = RR[ii][jj];
            U[ii][jj] = UU[ii][jj];
            D[ii][jj] = DD[ii][jj];
          }
        }
        queue<pair<int, int> > q;
        q.push(make_pair(i, j));
        int sum = 0;
        while (!q.empty()) {
          auto it = q.front();
          q.pop();
          sum++;
          if (R[it.first][it.second] != make_pair(-1, -1)) {
            L[R[it.first][it.second].first][R[it.first][it.second].second] =
                L[it.first][it.second];
          }
          if (L[it.first][it.second] != make_pair(-1, -1)) {
            R[L[it.first][it.second].first][L[it.first][it.second].second] =
                R[it.first][it.second];
          }
          if (U[it.first][it.second] != make_pair(-1, -1)) {
            D[U[it.first][it.second].first][U[it.first][it.second].second] =
                D[it.first][it.second];
          }
          if (D[it.first][it.second] != make_pair(-1, -1)) {
            U[D[it.first][it.second].first][D[it.first][it.second].second] =
                U[it.first][it.second];
          }
          if (a[it.first][it.second] == 'L') {
            if (L[it.first][it.second] != make_pair(-1, -1)) {
              q.push(L[it.first][it.second]);
            }
          } else if (a[it.first][it.second] == 'R') {
            if (R[it.first][it.second] != make_pair(-1, -1)) {
              q.push(R[it.first][it.second]);
            }
          } else if (a[it.first][it.second] == 'U') {
            if (U[it.first][it.second] != make_pair(-1, -1)) {
              q.push(U[it.first][it.second]);
            }
          } else {
            if (D[it.first][it.second] != make_pair(-1, -1)) {
              q.push(D[it.first][it.second]);
            }
          }
        }
        if (sum > mx) {
          mx = sum;
          cur = 1;
        } else if (sum == mx) {
          cur++;
        }
      }
    }
  }
  cout << mx << " " << cur;
}
