#include <bits/stdc++.h>
int n, m, ans;
int L[10010], R[10010], U[10010], D[10010], col[10010], sum[10010], row[10010];
char s[5010][5010];
int node;
void build(int n, int m) {
  int head = 0;
  L[0] = m;
  R[0] = 1;
  for (int i = 1; i <= m; i++) {
    L[i] = i - 1;
    R[i] = (i + 1) % (m + 1);
    col[i] = U[i] = D[i] = i;
    sum[i] = 0;
  }
  node = m;
  for (int i = 1; i <= n; i++) {
    int head = 0;
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '.') continue;
      node++;
      D[U[j]] = node;
      U[node] = U[j];
      D[node] = j;
      U[j] = node;
      if (!head) {
        head = node;
        L[head] = R[head] = head;
      } else {
        L[node] = L[head];
        R[node] = head;
        R[L[node]] = node;
        L[head] = node;
      }
      col[node] = j;
      row[node] = i;
      sum[j]++;
    }
  }
}
void remove(int node) {
  L[R[node]] = L[node];
  R[L[node]] = R[node];
  U[D[node]] = U[node];
  D[U[node]] = D[node];
}
void resume(int node) {
  U[D[node]] = node;
  D[U[node]] = node;
  L[R[node]] = node;
  R[L[node]] = node;
}
void dfs(int id) {
  ans++;
  int x = row[id];
  int y = col[id];
  if (y == 0) {
    x--;
    y = m;
  }
  if (s[x][y] == 'D') {
    if (D[id] > id) {
      remove(id);
      dfs(D[id]);
      resume(id);
    }
  } else if (s[x][y] == 'U') {
    if (U[id] < id && U[id] > m) {
      remove(id);
      dfs(U[id]);
      resume(id);
    }
  } else if (s[x][y] == 'L') {
    if (L[id] < id) {
      remove(id);
      dfs(L[id]);
      resume(id);
    }
  } else {
    if (R[id] > id) {
      remove(id);
      dfs(R[id]);
      resume(id);
    }
  }
}
int test(int id) {
  ans = 0;
  dfs(id);
  return ans;
}
int main() {
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
    build(n, m);
    int maxx = 0, num = 1;
    for (int ii = m + 1; ii <= node; ii++) {
      int ans = test(ii);
      if (ans > maxx) {
        maxx = ans;
        num = 1;
      } else if (ans == maxx)
        num++;
    }
    printf("%d %d\n", maxx, num);
  }
  return 0;
}
