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 A[MAXN][MAXN];
set<int> X[MAXN];
set<int> Y[MAXN];
bool V[MAXN][MAXN];
void read_data() {
  scanf("%d %d", &M, &N);
  for (int(i) = (1); (i) <= (M); (i)++) scanf("%s", A[i] + 1);
  for (int(i) = (1); (i) <= (M); (i)++)
    for (int(j) = (1); (j) <= (N); (j)++)
      if (A[i][j] != '.') {
        X[i].insert(j);
        Y[j].insert(i);
      }
}
pair<int, int> FAIL(-1, -1);
static inline pair<int, int> next(int x, int y) {
  if (A[x][y] == 'U') {
    set<int>::iterator it = Y[y].upper_bound(x - 1);
    if (it == Y[y].begin())
      return FAIL;
    else {
      --it;
      return make_pair(*it, y);
    }
  }
  if (A[x][y] == 'D') {
    set<int>::iterator it = Y[y].lower_bound(x + 1);
    if (it == Y[y].end())
      return FAIL;
    else
      return make_pair(*it, y);
  }
  if (A[x][y] == 'L') {
    set<int>::iterator it = X[x].upper_bound(y - 1);
    if (it == X[x].begin())
      return FAIL;
    else {
      --it;
      return make_pair(x, *it);
    }
  }
  if (A[x][y] == 'R') {
    set<int>::iterator it = X[x].lower_bound(y + 1);
    if (it == X[x].end())
      return FAIL;
    else
      return make_pair(x, *it);
  }
  cout << "ITS BAD!" << endl;
  return FAIL;
}
pair<pair<int, int>, char> S[MAXN];
int check(int x, int y) {
  int s = 0;
  if (A[x][y] == '.' or V[x][y])
    return 0;
  else {
    V[x][y] = true;
    pair<int, int> coords;
    do {
      ++s;
      S[s].first = make_pair(x, y);
      S[s].second = A[x][y];
      X[x].erase(y);
      Y[y].erase(x);
      coords = next(x, y);
      x = coords.first;
      y = coords.second;
      V[x][y] = true;
    } while (coords != FAIL);
  }
  int result = s;
  for (int(i) = (1); (i) <= (s); (i)++) {
    X[S[i].first.first].insert(S[i].first.second);
    Y[S[i].first.second].insert(S[i].first.first);
    A[S[i].first.first][S[i].first.second] = S[i].second;
  }
  return result;
}
void solve() {
  map<int, int> R;
  for (int(i) = (1); (i) <= (M); (i)++)
    for (int(j) = (1); (j) <= (N); (j)++)
      if (A[i][j] != '.') R[check(i, j)]++;
  printf("%d %d\n", R.rbegin()->first, R.rbegin()->second);
}
int main() {
  read_data();
  solve();
  return 0;
}
