#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int n, m;
char s[N + 10][N + 10];
int L[N + 10], R[N + 10], U[N + 10], D[N + 10], l[N + 10], r[N + 10], u[N + 10],
    d[N + 10];
int rec[N + 10][N + 10], id[N + 10][2];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  memset(L, 0, sizeof(L));
  memset(R, 0, sizeof(R));
  memset(U, 0, sizeof(U));
  memset(D, 0, sizeof(D));
  memset(id, 0, sizeof(id));
  memset(rec, 0, sizeof(rec));
  int tot = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] != '.') {
        rec[i][j] = ++tot;
        id[tot][0] = i;
        id[tot][1] = j;
      }
  for (int i = 0; i < n; ++i) {
    int e;
    for (int j = 0, e = 0; j < m; ++j) {
      if (s[i][j] != '.') {
        if (e > 0)
          L[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
    for (int j = m - 1, e = 0; j >= 0; --j) {
      if (s[i][j] != '.') {
        if (e > 0)
          R[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
  }
  for (int j = 0; j < m; ++j) {
    int e;
    for (int i = 0, e = 0; i < n; ++i) {
      if (s[i][j] != '.') {
        if (e > 0)
          U[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
    for (int i = n - 1, e = 0; i >= 0; --i) {
      if (s[i][j] != '.') {
        if (e > 0)
          D[rec[i][j]] = e, e = rec[i][j];
        else
          e = rec[i][j];
      }
    }
  }
  int best = 0;
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    for (int j = 1; j <= tot; ++j)
      l[j] = L[j], r[j] = R[j], u[j] = U[j], d[j] = D[j];
    int count = 0;
    int cur = i;
    int next;
    for (;;) {
      count++;
      if (s[id[cur][0]][id[cur][1]] == 'L') next = l[cur];
      if (s[id[cur][0]][id[cur][1]] == 'R') next = r[cur];
      if (s[id[cur][0]][id[cur][1]] == 'U') next = u[cur];
      if (s[id[cur][0]][id[cur][1]] == 'D') next = d[cur];
      if (l[cur] != 0) r[l[cur]] = r[cur];
      if (r[cur] != 0) l[r[cur]] = l[cur];
      if (u[cur] != 0) d[u[cur]] = d[cur];
      if (d[cur] != 0) u[d[cur]] = u[cur];
      if (next == 0) break;
      cur = next;
    }
    if (count > best) {
      best = count;
      cnt = 1;
    } else if (count == best) {
      cnt++;
    }
  }
  printf("%d %d\n", best, cnt);
  return 0;
}
