#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;
}
