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 signed long long Infinity = 1000000001;
const long double Epsilon = 1e-9;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& V) {
  os << "[";
  for (__typeof(V.begin()) i = V.begin(); i != V.end(); ++i)
    os << *i << (i - V.begin() + 1 == ((int)V.size()) ? "" : ",");
  os << "]\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& S) {
  os << "(";
  for (__typeof(S.begin()) i = S.begin(); i != S.end(); ++i)
    os << *i << (*i == *S.rbegin() ? "" : ",");
  os << ")\n";
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& M) {
  os << "{";
  for (__typeof(M.begin()) i = M.begin(); i != M.end(); ++i)
    os << *i << (i->first == M.rbegin()->first ? "" : ",");
  os << "}\n";
  return os;
}
const int MAXN = 5010;
int M, N;
char buff[MAXN];
string A[MAXN];
vector<pair<int, int> > L[MAXN];
vector<pair<int, int> > R[MAXN];
vector<pair<int, int> > U[MAXN];
vector<pair<int, int> > D[MAXN];
pair<int, int> FAIL(-1, -1);
void read_data() {
  scanf("%d %d", &M, &N);
  for (int(i) = (1); (i) <= (M); (i)++) {
    scanf("%s", buff);
    A[i] = " " + string(buff);
  }
  for (int(i) = (1); (i) <= (M); (i)++) {
    L[i].resize(N + 2, FAIL);
    R[i].resize(N + 2, FAIL);
    U[i].resize(N + 2, FAIL);
    D[i].resize(N + 2, FAIL);
  }
}
void off(int x, int y) {
  if (L[x][y] != FAIL) R[L[x][y].first][L[x][y].second] = R[x][y];
  if (R[x][y] != FAIL) L[R[x][y].first][R[x][y].second] = L[x][y];
  if (D[x][y] != FAIL) U[D[x][y].first][D[x][y].second] = U[x][y];
  if (U[x][y] != FAIL) D[U[x][y].first][U[x][y].second] = D[x][y];
}
void on(int x, int y) {
  if (L[x][y] != FAIL) R[L[x][y].first][L[x][y].second] = make_pair(x, y);
  if (R[x][y] != FAIL) L[R[x][y].first][R[x][y].second] = make_pair(x, y);
  if (D[x][y] != FAIL) U[D[x][y].first][D[x][y].second] = make_pair(x, y);
  if (U[x][y] != FAIL) D[U[x][y].first][U[x][y].second] = make_pair(x, y);
}
int check(int x, int y) {
  if (x < 1 or x > M or y < 1 or y > N) return 0;
  if (A[x][y] == '.') return 0;
  off(x, y);
  int result;
  if (A[x][y] == 'D') result = 1 + check(D[x][y].first, y);
  if (A[x][y] == 'U') result = 1 + check(U[x][y].first, y);
  if (A[x][y] == 'L') result = 1 + check(x, L[x][y].second);
  if (A[x][y] == 'R') result = 1 + check(x, R[x][y].second);
  on(x, y);
  return result;
}
void solve() {
  for (int(i) = (1); (i) <= (M); (i)++) {
    int last = -1;
    for (int(j) = (1); (j) <= (N); (j)++)
      if (A[i][j] != '.') {
        if (last != -1) L[i][j] = make_pair(i, last);
        last = j;
      }
    last = -1;
    for (int(j) = (N); (j) >= (1); (j)--)
      if (A[i][j] != '.') {
        if (last != -1) R[i][j] = make_pair(i, last);
        last = j;
      }
  }
  for (int(i) = (1); (i) <= (N); (i)++) {
    int last = -1;
    for (int(j) = (1); (j) <= (M); (j)++)
      if (A[j][i] != '.') {
        if (last != -1) U[j][i] = make_pair(last, i);
        last = j;
      }
    last = -1;
    for (int(j) = (M); (j) >= (1); (j)--)
      if (A[j][i] != '.') {
        if (last != -1) D[j][i] = make_pair(last, i);
        last = j;
      }
  }
  map<int, int> Re;
  for (int(i) = (1); (i) <= (M); (i)++)
    for (int(j) = (1); (j) <= (N); (j)++)
      if (A[i][j] != '.') Re[check(i, j)]++;
  printf("%d %d\n", Re.rbegin()->first, Re.rbegin()->second);
}
int main() {
  read_data();
  solve();
  return 0;
}
