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