#include <bits/stdc++.h>
using namespace std;
string s[8002];
int l[8002][6];
int n, m, t;
int a[8002];
char *pat = "LRUD.";
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
bool vis[8002];
int cnt[8002];
int go(int t) {
  int x = t / m, y = t % m, res = 0;
  while (1) {
    ++res;
    int nxt = l[t][a[t]];
    if (nxt == -1) break;
    for (int i = 0; i < 4; i++) {
      if (l[t][i ^ 1] == -1) continue;
      l[l[t][i ^ 1]][i] = l[t][i];
    }
    t = nxt;
  }
  return res;
}
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  t = n * m;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    for (j = 0; j < m; j++) {
      a[i * m + j] = strchr(pat, s[i][j]) - pat;
    }
  }
  int mx = 0, cnt = 0;
  for (k = 0; k < t; k++) {
    if (a[k] == 4) continue;
    memset(l, -1, sizeof(l));
    for (i = 0; i < t; i++) {
      if (a[i] == 4) continue;
      for (j = 0; j < 4; j++) {
        int x = i / m, y = i % m;
        while (1) {
          x += dx[j];
          y += dy[j];
          if (x < 0 || x >= n || y < 0 || y >= m) break;
          if (a[x * m + y] == 4) continue;
          l[i][j] = x * m + y;
          break;
        }
      }
    }
    int tt = go(k);
    if (tt > mx) {
      mx = tt;
      cnt = 1;
    } else if (tt == mx) {
      cnt++;
    }
  }
  printf("%d %d\n", mx, cnt);
  return 0;
}
