#include <bits/stdc++.h>
using namespace std;
string st = "UDLR.";
string a[5006];
char s[5006];
int p1[5006][4], p2[5006][4], b[5006];
int num[5006][5006];
int n, m, k, ans, ans1, nn;
int main() {
  nn = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    a[i] = s;
  }
  memset(p1, 0, sizeof(p1));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j - 1] != '.') num[i][j] = ++nn;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j - 1] != '.') {
        int mm = num[i][j];
        b[mm] = st.find(a[i][j - 1]);
        for (int k = i - 1; k > 0; --k)
          if (a[k][j - 1] != '.') {
            p1[mm][0] = num[k][j];
            break;
          }
        for (int k = i + 1; k <= n; ++k)
          if (a[k][j - 1] != '.') {
            p1[mm][1] = num[k][j];
            break;
          }
        for (int k = j - 1; k > 0; --k)
          if (a[i][k - 1] != '.') {
            p1[mm][2] = num[i][k];
            break;
          }
        for (int k = j + 1; k <= m; ++k)
          if (a[i][k - 1] != '.') {
            p1[mm][3] = num[i][k];
            break;
          }
      }
  ans = ans1 = 0;
  for (int i = 1; i <= nn; ++i) {
    memcpy(p2, p1, sizeof(p1));
    int j = i, tmp = 0;
    while (j) {
      p2[p2[j][0]][1] = p2[j][1];
      p2[p2[j][1]][0] = p2[j][0];
      p2[p2[j][2]][3] = p2[j][3];
      p2[p2[j][3]][2] = p2[j][2];
      ++tmp;
      j = p2[j][b[j]];
    }
    if (tmp > ans) {
      ans = tmp;
      ans1 = 1;
    } else if (tmp == ans)
      ans1++;
  }
  printf("%d %d\n", ans, ans1);
  return 0;
}
