#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}
const int N = 5005;
int usti[N];
int asti[N];
int onni[N];
int soli[N];
int USTI[N];
int ASTI[N];
int ONNI[N];
int SOLI[N];
char letter[N];
int num[N][N];
char a[N][N];
int main() {
  int K = 0;
  int n = readInt(), m = readInt();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] != '.') {
        K++;
        num[i][j] = K;
        letter[K] = a[i][j];
      }
    }
  }
  int tmp;
  for (int i = 1; i <= n; i++) {
    tmp = -1;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '.') {
        soli[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
    tmp = -1;
    for (int j = m; j >= 1; j--) {
      if (a[i][j] != '.') {
        onni[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    tmp = -1;
    for (int i = 1; i <= n; i++) {
      if (a[i][j] != '.') {
        usti[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
    tmp = -1;
    for (int i = n; i >= 1; i--) {
      if (a[i][j] != '.') {
        asti[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
  }
  int mx = 0;
  int res = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      SOLI[j] = soli[j], ONNI[j] = onni[j], USTI[j] = usti[j],
      ASTI[j] = asti[j];
    }
    int cnt = 0;
    for (int z = i, j; z != -1; z = j) {
      if (letter[z] == 'L') j = SOLI[z];
      if (letter[z] == 'R') j = ONNI[z];
      if (letter[z] == 'U') j = USTI[z];
      if (letter[z] == 'D') j = ASTI[z];
      if (ONNI[z] != -1) SOLI[ONNI[z]] = SOLI[z];
      if (SOLI[z] != -1) ONNI[SOLI[z]] = ONNI[z];
      if (USTI[z] != -1) ASTI[USTI[z]] = ASTI[z];
      if (ASTI[z] != -1) USTI[ASTI[z]] = USTI[z];
      cnt++;
    }
    if (cnt > mx) mx = cnt, res = 0;
    if (cnt == mx) res++;
  }
  cout << mx << ' ' << res;
  return 0;
}
