#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
inline void read(long long *a, long long n) {
  for (long long i = 0; i < n; i++) a[i] = in();
}
template <class blank>
inline void out(blank x) {
  cout << x << "\n";
  exit(0);
}
template <class blank>
inline void smin(blank &a, blank b) {
  a = min(a, b);
}
template <class blank>
inline void smax(blank &a, blank b) {
  a = max(a, b);
}
const long long maxn = 1e5 + 10;
const long long maxm = 1e6 + 10;
const long long maxlg = 21;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 10;
const long long SQ = 317 + 5;
struct node {
  node *right, *left, *up, *down;
  char ch;
  node() { right = left = up = down = NULL; }
} * cell[5005], *cpcell[5005];
string s[maxn];
long long res, cnt, n, m;
inline long long dfs(node *node) {
  long long ret = 1;
  if (node->left != NULL) node->left->right = node->right;
  if (node->right != NULL) node->right->left = node->left;
  if (node->down != NULL) node->down->up = node->up;
  if (node->up != NULL) node->up->down = node->down;
  if (node->ch == 'U') {
    if (node->up != NULL) return ret + dfs(node->up);
  }
  if (node->ch == 'D') {
    if (node->down != NULL) {
      return ret + dfs(node->down);
    }
  }
  if (node->ch == 'L')
    if (node->left != NULL) return ret + dfs(node->left);
  if (node->ch == 'R')
    if (node->right != NULL) return ret + dfs(node->right);
  return ret;
}
int32_t main() {
  n = in(), m = in();
  for (long long i = 0; i < n; i++) {
    s[i] = get();
    for (long long j = 0; j < m; j++) {
      cell[i * m + j] = new node();
      cell[i * m + j]->ch = s[i][j];
      cpcell[i * m + j] = new node();
    }
  }
  for (long long startX = 0; startX < n; startX++) {
    for (long long startY = 0; startY < m; startY++) {
      if (s[startX][startY] == '.') continue;
      for (long long i = 0; i < n; i++) {
        long long preLeft = -1;
        for (long long j = 0; j < m; j++) {
          if (s[i][j] == '.') continue;
          long long nodeId = i * m + j;
          if (preLeft + 1) {
            cell[preLeft]->right = cell[nodeId];
            cell[nodeId]->left = cell[preLeft];
          }
          preLeft = nodeId;
        }
      }
      for (long long j = 0; j < m; j++) {
        long long preUp = -1;
        for (long long i = 0; i < n; i++) {
          if (s[i][j] == '.') continue;
          long long nodeId = i * m + j;
          if (preUp + 1)
            cell[preUp]->down = cell[nodeId], cell[nodeId]->up = cell[preUp];
          preUp = nodeId;
        }
      }
      long long val = dfs(cell[startX * m + startY]);
      if (val == res)
        cnt++;
      else if (val > res)
        cnt = 1, res = val;
    }
  }
  cout << res << " " << cnt << "\n";
}
