#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool gmin(T &a, T b) {
  if (a > b) return a = b, true;
  return false;
}
template <class T>
inline bool gmax(T &a, T b) {
  if (a < b) return a = b, true;
  return false;
}
template <class T>
T exgcd(T a, T b, T &first, T &second) {
  if (!b)
    return first = (T)1, second = (T)0, a;
  else {
    T d = exgcd(b, a % b, second, first);
    return second -= a / b * first, d;
  }
}
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = 1e10;
const double EPS = 1e-9;
const double PI = 3.14159265358979323846264338327950288;
const double TAU = 2.0 * PI;
inline int sgn(const double &a) { return a > EPS ? 1 : (a < -EPS ? -1 : 0); }
inline int lowbit(int i) { return i & (-i); }
struct Initializer {
  Initializer() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
} initializer;
const int MAXN = 5005;
int n, m;
int tol[MAXN], tor[MAXN], tou[MAXN], tod[MAXN];
int l[MAXN], r[MAXN], d[MAXN], u[MAXN];
char t[MAXN][MAXN];
inline int idx(int i, int j) { return (i - 1) * n + j; }
void update(int i, int j) {
  if (r[idx(i, j)]) l[idx(i, r[idx(i, j)])] = l[idx(i, j)];
  if (l[idx(i, j)]) r[idx(i, l[idx(i, j)])] = r[idx(i, j)];
  if (u[idx(i, j)]) d[idx(u[idx(i, j)], j)] = d[idx(i, j)];
  if (d[idx(i, j)]) u[idx(d[idx(i, j)], j)] = u[idx(i, j)];
}
int main() {
  scanf("%d %d", &m, &n);
  for (int i = 1; i <= m; i++) scanf("%s", t[i] + 1);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      for (int k = j - 1; k >= 1; k--)
        if (t[i][k] != '.') {
          tol[idx(i, j)] = k;
          break;
        }
      for (int k = i - 1; k >= 1; k--)
        if (t[k][j] != '.') {
          tou[idx(i, j)] = k;
          break;
        }
      for (int k = j + 1; k <= n; k++)
        if (t[i][k] != '.') {
          tor[idx(i, j)] = k;
          break;
        }
      for (int k = i + 1; k <= m; k++)
        if (t[k][j] != '.') {
          tod[idx(i, j)] = k;
          break;
        }
    }
  int ans = 0, cnt = 0;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (t[i][j] != '.') {
        for (int p = 1; p <= m; p++)
          for (int q = 1; q <= n; q++) {
            l[idx(p, q)] = tol[idx(p, q)];
            r[idx(p, q)] = tor[idx(p, q)];
            u[idx(p, q)] = tou[idx(p, q)];
            d[idx(p, q)] = tod[idx(p, q)];
          }
        int rec = 0;
        for (int first = i, second = j; first && second;) {
          rec++;
          update(first, second);
          switch (t[first][second]) {
            case 'L':
              second = l[idx(first, second)];
              break;
            case 'R':
              second = r[idx(first, second)];
              break;
            case 'U':
              first = u[idx(first, second)];
              break;
            case 'D':
              first = d[idx(first, second)];
              break;
          }
        }
        if (rec > ans)
          ans = rec, cnt = 1;
        else {
          if (rec == ans) cnt++;
        }
      }
  printf("%d %d\n", ans, cnt);
  return 0;
}
