#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
char s[N];
char mp[N];
int up[N], down[N], leftt[N], rightt[N];
int u[N], d[N], l[N], r[N];
int sum;
int tot;
int n, m, nm;
void bfs(int t) {
  while (1) {
    sum++;
    int x = t;
    int tmp = x % m;
    if (tmp == 0) tmp = m;
    int liml = x - tmp + 1, limr = liml + m - 1;
    if (mp[t] == 'L') {
      x = leftt[x];
      if (x == 0) break;
    } else if (mp[t] == 'R') {
      x = rightt[x];
      if (x == 0) break;
    } else if (mp[t] == 'U') {
      x = up[x];
      if (x == 0) break;
    } else if (mp[t] == 'D') {
      x = down[x];
      if (x == 0) break;
    }
    if (leftt[t] != 0) rightt[leftt[t]] = rightt[t];
    if (rightt[t] != 0) leftt[rightt[t]] = leftt[t];
    if (up[t] != 0) down[up[t]] = down[t];
    if (down[t] != 0) up[down[t]] = up[t];
    t = x;
  }
}
void finds(int x) {
  int tmp = x % m;
  if (tmp == 0) tmp = m;
  int liml = x - tmp + 1, limr = liml + m - 1;
  int t = x - m;
  while (t > 0 && mp[t] == '.') t -= m;
  if (t <= 0) t = 0;
  up[x] = t;
  t = x + m;
  while (t <= nm && mp[t] == '.') t += m;
  if (t > nm) t = 0;
  down[x] = t;
  t = x - 1;
  while (t >= liml && mp[t] == '.') t--;
  if (t < liml) t = 0;
  leftt[x] = t;
  t = x + 1;
  while (t <= limr && mp[t] == '.') t++;
  if (t > limr) t = 0;
  rightt[x] = t;
  u[x] = up[x];
  d[x] = down[x];
  l[x] = leftt[x];
  r[x] = rightt[x];
}
void clean() {
  for (int i = 1; i <= nm; i++)
    leftt[i] = l[i], rightt[i] = r[i], up[i] = u[i], down[i] = d[i];
}
int main() {
  scanf("%d%d", &n, &m);
  nm = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++) mp[++nm] = s[j];
  }
  for (int i = 1; i <= nm; i++) finds(i);
  int ans = 0, t = 0;
  for (int i = 1; i <= nm; i++)
    if (mp[i] != '.') {
      sum = 0;
      clean();
      bfs(i);
      if (sum > ans) {
        ans = sum;
        t = 1;
      } else if (sum == ans)
        t++;
    }
  printf("%d %d\n", ans, t);
  return 0;
}
