#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, m, up[5005], dw[5005], pr[5005], nx[5005];
int upp[5005], dww[5005], prr[5005], nxx[5005];
char mp[5005][5005];
inline void initialize() {
  for (int k = 0; k < n; k++)
    for (int l = 0; l < m; l++) {
      up[k * m + l] = upp[k * m + l];
      dw[k * m + l] = dww[k * m + l];
      nx[k * m + l] = nxx[k * m + l];
      pr[k * m + l] = prr[k * m + l];
    }
}
inline void del(int x) {
  nx[pr[x]] = nx[x];
  pr[nx[x]] = pr[x];
  up[dw[x]] = up[x];
  dw[up[x]] = dw[x];
}
int main() {
  int t = 0, T = 0;
  scanf("%d%d", &n, &m);
  getchar();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%c", &mp[i][j]);
    getchar();
  }
  memset(up, -1, sizeof(up));
  memset(dw, -1, sizeof(dw));
  memset(nx, -1, sizeof(nx));
  memset(pr, -1, sizeof(pr));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.') continue;
      for (int k = i - 1; k >= 0; k--)
        if (mp[k][j] != '.') {
          up[i * m + j] = k * m + j;
          break;
        }
      for (int k = i + 1; k < n; k++)
        if (mp[k][j] != '.') {
          dw[i * m + j] = k * m + j;
          break;
        }
      for (int k = j + 1; k < m; k++)
        if (mp[i][k] != '.') {
          nx[i * m + j] = i * m + k;
          break;
        }
      for (int k = j - 1; k >= 0; k--)
        if (mp[i][k] != '.') {
          pr[i * m + j] = i * m + k;
          break;
        }
    }
  }
  for (int k = 0; k < n; k++)
    for (int l = 0; l < m; l++) {
      upp[k * m + l] = up[k * m + l];
      dww[k * m + l] = dw[k * m + l];
      nxx[k * m + l] = nx[k * m + l];
      prr[k * m + l] = pr[k * m + l];
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.') continue;
      int x = i, y = j, len = 1;
      initialize();
      del(i * m + j);
      while (1) {
        int k = x * m + y;
        if (mp[x][y] == 'U' && up[k] >= 0)
          x = up[k] / m;
        else if (mp[x][y] == 'D' && dw[k] >= 0)
          x = dw[k] / m;
        else if (mp[x][y] == 'R' && nx[k] >= 0)
          y = nx[k] % m;
        else if (mp[x][y] == 'L' && pr[k] >= 0)
          y = pr[k] % m;
        else
          break;
        del(k);
        len++;
      }
      if (len > ans)
        ans = len, T = 1;
      else if (len == ans)
        T++;
    }
  }
  printf("%d %d\n", ans, T);
  return 0;
}
