#include <bits/stdc++.h>
using namespace std;
const int N = 5036;
bool vis[N][N];
char s[N][N];
short pr[2][N][N];
short ne[2][N][N];
int n, m;
void ER(int first, int second, char c) {
  if (vis[first][second]) return;
  vis[first][second] = 1;
  {
    int v1 = pr[0][first][second];
    int v2 = ne[0][first][second];
    if (v2 != -1) pr[0][first][v2] = v1;
    if (v1 != -1) ne[0][first][v1] = v2;
  }
  {
    int u1 = pr[1][first][second];
    int u2 = ne[1][first][second];
    if (u2 != -1) pr[1][u2][second] = u1;
    if (u1 != -1) ne[1][u1][second] = u2;
  }
}
void LK(int first, int second, int a, int b) {
  if (first == a) {
    ne[0][first][second] = b;
    pr[0][first][b] = second;
  } else {
    ne[1][first][second] = a;
    pr[1][a][second] = first;
  }
}
void init() {
  for (int k = (0); k < (int)(2); k++)
    for (int i = (0); i < (int)(n); i++)
      for (int j = (0); j < (int)(m); j++) {
        pr[k][i][j] = -1;
        ne[k][i][j] = -1;
        vis[i][j] = 0;
      }
  for (int first = (0); first < (int)(n); first++) {
    int second = 0;
    while (second < m && s[first][second] == '.') ++second;
    for (; second < m;) {
      int v = second + 1;
      while (v < m && s[first][v] == '.') ++v;
      if (v >= m) break;
      LK(first, second, first, v);
      second = v;
    }
  }
  for (int second = (0); second < (int)(m); second++) {
    int first = 0;
    while (first < n && s[first][second] == '.') ++first;
    for (; first < n;) {
      int u = first + 1;
      while (u < n && s[u][second] == '.') ++u;
      if (u >= n) break;
      LK(first, second, u, second);
      first = u;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (int)(n); i++) scanf("%s", s[i]);
  int best = 0;
  int hv = n * m;
  for (int i = (0); i < (int)(n); i++)
    for (int j = (0); j < (int)(m); j++) {
      if (s[i][j] != '.') {
        init();
        int cur = 0;
        int first = i, second = j;
        while (first != -1 && second != -1) {
          int a, b;
          if (s[first][second] == 'R') {
            a = first;
            b = ne[0][first][second];
          } else if (s[first][second] == 'L') {
            a = first;
            b = pr[0][first][second];
          } else if (s[first][second] == 'D') {
            a = ne[1][first][second];
            b = second;
          } else if (s[first][second] == 'U') {
            a = pr[1][first][second];
            b = second;
          }
          ER(first, second, s[first][second]);
          first = a;
          second = b;
          ++cur;
        }
        if (cur == best) {
          hv++;
        } else if (cur > best) {
          best = cur;
          hv = 1;
        }
      }
    }
  printf("%d %d\n", best, hv);
  return 0;
}
