#include <bits/stdc++.h>
using namespace std;
const int MaxN = 5005;
vector<string> g;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
vector<int> Set[4][MaxN];
int Get(char c) {
  if (c == 'R') return 0;
  if (c == 'D') return 1;
  if (c == 'L') return 2;
  return 3;
}
int n, m;
bool check(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= m) return 0;
  return 1;
}
char s[MaxN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    string t = s;
    g.push_back(t);
    for (int j = 0; j < m; j++)
      for (int k = 0; k < 4; k++) Set[k][i].push_back(0);
  }
  int ret = 0, a = 0;
  for (int x = 0; x < n; x++)
    for (int y = 0; y < m; y++)
      if (g[x][y] != '.') {
        for (int i = 0; i < n; i++) {
          int p = -1;
          for (int j = 0; j < m; j++)
            if (g[i][j] != '.') {
              Set[2][i][j] = p;
              p = j;
            }
        }
        for (int i = 0; i < n; i++) {
          int p = m;
          for (int j = m - 1; j >= 0; j--)
            if (g[i][j] != '.') {
              Set[0][i][j] = p;
              p = j;
            }
        }
        for (int i = 0; i < m; i++) {
          int p = -1;
          for (int j = 0; j < n; j++)
            if (g[j][i] != '.') {
              Set[3][j][i] = p;
              p = j;
            }
        }
        for (int i = 0; i < m; i++) {
          int p = n;
          for (int j = n - 1; j >= 0; j--)
            if (g[j][i] != '.') {
              Set[1][j][i] = p;
              p = j;
            }
        }
        int nx = x, ny = y, ct = 1;
        while (1) {
          int d = Get(g[nx][ny]);
          int xx, yy;
          if (d == 0 || d == 2)
            xx = nx, yy = Set[d][nx][ny];
          else
            yy = ny, xx = Set[d][nx][ny];
          if (!check(xx, yy)) break;
          int tx[4], ty[4];
          for (d = 0; d < 4; d++) {
            if (d == 0 || d == 2)
              tx[d] = nx, ty[d] = Set[d][nx][ny];
            else
              ty[d] = ny, tx[d] = Set[d][nx][ny];
          }
          for (d = 0; d < 4; d++)
            if (check(tx[d], ty[d])) {
              Set[(d + 2) % 4][tx[d]][ty[d]] =
                  ((d == 0 || d == 2) ? ty[(d + 2) % 4] : tx[(d + 2) % 4]);
            }
          ct++;
          nx = xx, ny = yy;
        }
        if (ret < ct) {
          ret = ct;
          a = 1;
        } else if (ret == ct)
          a++;
      }
  printf("%d %d\n", ret, a);
  return 0;
}
