#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.txt");
ofstream fout("out.txt");
const int MAXN = 5120;
char a[MAXN][MAXN];
int RCON, CCON;
int L[MAXN], R[MAXN];
int U[MAXN], D[MAXN];
void prepare() {
  for (int i = (0); i <= (RCON - 1); i++) {
    int l = -1;
    for (int j = (0); j <= (CCON - 1); j++)
      if (a[i][j] != '.') {
        int ed = i * CCON + j;
        L[ed] = l;
        if (l != -1) R[l] = ed;
        l = ed;
      }
    R[l] = -1;
  }
  for (int i = (0); i <= (CCON - 1); i++) {
    int u = -1;
    for (int j = (0); j <= (RCON - 1); j++)
      if (a[j][i] != '.') {
        int ed = j * CCON + i;
        U[ed] = u;
        if (u != -1) D[u] = ed;
        u = ed;
      }
    D[u] = -1;
  }
}
void del(int i, int j) {
  int ed = i * CCON + j;
  if (U[ed] != -1) D[U[ed]] = D[ed];
  if (D[ed] != -1) U[D[ed]] = U[ed];
  if (L[ed] != -1) R[L[ed]] = R[ed];
  if (R[ed] != -1) L[R[ed]] = L[ed];
}
int dfs(int i, int j) {
  del(i, j);
  int ed = i * CCON + j;
  if (a[i][j] == 'U') {
    if (U[ed] == -1)
      return 1;
    else
      return 1 + dfs(U[ed] / CCON, j);
  } else if (a[i][j] == 'D') {
    if (D[ed] == -1)
      return 1;
    else
      return 1 + dfs(D[ed] / CCON, j);
  } else if (a[i][j] == 'L') {
    if (L[ed] == -1)
      return 1;
    else
      return 1 + dfs(i, L[ed] % CCON);
  } else if (a[i][j] == 'R') {
    if (R[ed] == -1)
      return 1;
    else
      return 1 + dfs(i, R[ed] % CCON);
  }
  return 0;
}
void openfile() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
void init() {
  scanf("%d %d", &RCON, &CCON);
  for (int i = 0; i < RCON; i++) scanf("%s", a[i]);
}
void solve() {
  int ans = -1, ans2;
  for (int i = (0); i <= (RCON - 1); i++)
    for (int j = (0); j <= (CCON - 1); j++)
      if (a[i][j] != '.') {
        prepare();
        int ret = dfs(i, j);
        if (ret > ans)
          ans = ret, ans2 = 1;
        else if (ret == ans)
          ans2++;
      }
  printf("%d %d\n", ans, ans2);
}
int main() {
  init();
  solve();
  return 0;
}
