#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int n, m;
vector<string> grid;
vector<vector<int> > l, r, u, d;
bool active[N];
int getpar(vector<vector<int> > &arr, int x, int y) {
  int nxt = arr[x][y];
  if (nxt == N - 1 || active[nxt]) return nxt;
  return arr[x][y] = getpar(arr, nxt / m, nxt % m);
}
int solve(int x, int y) {
  fill(active, active + N - 1, true);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') active[i * m + j] = false;
      l[i][j] = i * m + j - 1;
      r[i][j] = i * m + j + 1;
      u[i][j] = i * m + j - m;
      d[i][j] = i * m + j + m;
      if (i == 0) u[i][j] = N - 1;
      if (i == n - 1) d[i][j] = N - 1;
      if (j == 0) l[i][j] = N - 1;
      if (j == m - 1) r[i][j] = N - 1;
    }
  int ans = 1;
  while (true) {
    int nxt = N - 1;
    if (grid[x][y] == 'L') {
      nxt = getpar(l, x, y);
    }
    if (grid[x][y] == 'R') {
      nxt = getpar(r, x, y);
    }
    if (grid[x][y] == 'U') {
      nxt = getpar(u, x, y);
    }
    if (grid[x][y] == 'D') {
      nxt = getpar(d, x, y);
    }
    if (nxt == N - 1) return ans;
    active[x * m + y] = false;
    x = nxt / m;
    y = nxt % m;
    ++ans;
  }
}
int main() {
  cin >> n >> m;
  l = vector<vector<int> >(n, vector<int>(m));
  r = vector<vector<int> >(n, vector<int>(m));
  u = vector<vector<int> >(n, vector<int>(m));
  d = vector<vector<int> >(n, vector<int>(m));
  grid.resize(n);
  for (int i = 0; i < n; ++i) cin >> grid[i];
  vector<int> res;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] != '.') res.push_back(solve(i, j));
    }
  sort(res.rbegin(), res.rend());
  int i = 0;
  while (res[i] == res[0]) ++i;
  cout << res[0] << ' ' << i << '\n';
}
