#include <bits/stdc++.h>
int a[10001], up[10001], down[10001], left[10001], right[10001], n, m, now, ans,
    total;
bool b[10001];
void readin() {
  int i, j, last[10001], pre, num;
  char tmp, ch;
  scanf("%d %d", &n, &m);
  scanf("%c", &tmp);
  num = n * m;
  for (i = 1; i <= m; ++i) last[10001] = -1;
  for (i = 1; i <= num; ++i) up[i] = down[i] = left[i] = right[i] = -1;
  for (i = 1; i <= n; ++i) {
    pre = -1;
    for (j = 1; j <= m; ++j) {
      b[(i - 1) * m + j] = false;
      scanf("%c", &ch);
      switch (ch) {
        case '.':
          a[(i - 1) * m + j] = 0;
          break;
        case 'U':
          a[(i - 1) * m + j] = 1;
          break;
        case 'D':
          a[(i - 1) * m + j] = 2;
          break;
        case 'L':
          a[(i - 1) * m + j] = 3;
          break;
        case 'R':
          a[(i - 1) * m + j] = 4;
          break;
      }
      if (ch == '.') continue;
      if (last[j] > 0) {
        up[(i - 1) * m + j] = last[j];
        down[last[j]] = (i - 1) * m + j;
      }
      last[j] = (i - 1) * m + j;
      if (pre > 0) {
        left[(i - 1) * m + j] = pre;
        right[pre] = (i - 1) * m + j;
      }
      pre = (i - 1) * m + j;
    }
    scanf("%c", &tmp);
  }
}
void del(int t) {
  if (up[t] > 0) down[up[t]] = down[t];
  if (down[t] > 0) up[down[t]] = up[t];
  if (left[t] > 0) right[left[t]] = right[t];
  if (right[t] > 0) left[right[t]] = left[t];
}
void back(int t) {
  if (up[t] > 0) down[up[t]] = t;
  if (down[t] > 0) up[down[t]] = t;
  if (left[t] > 0) right[left[t]] = t;
  if (right[t] > 0) left[right[t]] = t;
}
void search(int t) {
  int i, x, y;
  if (t < 0 || t > n * m) return;
  y = t % m;
  if (y == 0) {
    x = t / m;
    y = m;
  } else
    x = t / m + 1;
  b[t] = true;
  ++now;
  if (now == ans) ++total;
  if (now > ans) {
    ans = now;
    total = 1;
  }
  switch (a[t]) {
    case 1:
      del(t);
      search(up[t]);
      back(t);
      break;
    case 2:
      del(t);
      search(down[t]);
      back(t);
      break;
    case 3:
      del(t);
      search(left[t]);
      back(t);
      break;
    case 4:
      del(t);
      search(right[t]);
      back(t);
      break;
  }
  --now;
  b[t] = false;
}
void solve() {
  int i, j;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      if (a[(i - 1) * m + j] > 0) {
        now = 0;
        search((i - 1) * m + j);
        if (now > ans) {
          ans = now;
          total = 1;
          continue;
        }
        if (now == ans) ++total;
      }
}
void print() { printf("%d %d\n", ans, total); }
int main() {
  readin();
  solve();
  print();
  return 0;
}
